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 |
Beta Was this translation helpful? Give feedback.
-
@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. |
Beta Was this translation helpful? Give feedback.
-
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; |
Beta Was this translation helpful? Give feedback.
-
Relates to #520 (allow |
Beta Was this translation helpful? Give feedback.
-
Later type detection for variable defined with var should be allowed. Following should work
and
Beta Was this translation helpful? Give feedback.
All reactions