Replies: 4 comments
|
I think it would make the code a lot less readable to have to scan through the code to find an eventual initialization to determine the type of the variable. Given that |
|
@HaloFour for second case compiler error if GetValue returns int or something that isn't nullable. For multiple assingments it would work like ? : does now. Meaning types would have to be compatible. Visual Studio already shows var variables type if put mouse pointer top of it. So no need to scan through code. |
|
You first example would be addressed with lock and using expressions: var value = lock(_obj) GetValue();Your second example is already handled with a ternary expression: var value = condition ? GetValue() : null; |
|
Relates to #520 (allow |
Uh oh!
There was an error while loading. Please reload this page.
Later type detection for variable defined with var should be allowed. Following should work
and
All reactions