-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow implicitly typed variable(var) in methods optional paramters #14066
Comments
Um, how do you propose that the compiler work out that |
Why? It's not likely to be something like |
As @DavidArno said, for all default values (null, zero and other structs) you will require to specify the type anyways. I'd prefer #7737 as it helps with consistency, conciseness and DRY. void SomeMethod(string str = default, int id = default, CancellationToken ct = default) As for non-default values like |
@DavidArno oh sorry I mean,
What I mean is that when we can do
why not this,
|
I'm no fan of default/optional parameters and would always go for the following instead: someMethod() => ...
someMethodWithString(string s) => ... |
Closing as this doesn't appear to have much support. Having said that, if you want to continue to pursue this discussion, please open a new thread in |
Let's say we have this method,
It will be great if we have something like,
Due to optional parameter, compiler can easily determines the type. Just a suggestion.
The text was updated successfully, but these errors were encountered: