Optional Parameters in any order #2622
-
Right now I write code like the following:
and I call it like follows:
It would be really nice if C# could infer the position of optional parameters by their type so I could simply say:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Considering that methods can have multiple optional parameters of the same type I don't see how that could work. It also sounds like an unmitigated nightmare where it affects overload resolution. The C# compiler does now allow you to specify optional parameters in any order by name, so the third example: |
Beta Was this translation helpful? Give feedback.
Considering that methods can have multiple optional parameters of the same type I don't see how that could work. It also sounds like an unmitigated nightmare where it affects overload resolution.
The C# compiler does now allow you to specify optional parameters in any order by name, so the third example:
Foo(Another: new AnotherObject());
does work. Is that not sufficient?