declaration - Why doesn't C# let you declare multiple variables using var? -


given following:

// not problem int = 2, j = 3; 

so surprises me this:

// compiler error: implicitly-typed local variables cannot have multiple declarators var = 2, j = 3; 

doesn't compile. maybe there don't understand (which why i'm asking this)?

but why wouldn't compiler realize meant:

var = 2; var j = 3; 

which compile.

it's point of possible confusion programmer , compiler.

for example fine:

double = 2, j = 3.4; 

but mean?

var = 2, j = 3.4; 

with syntactic sugar kind of thing headache no 1 needs--so doubt case ever supported. involves of compiler trying little bit clever.


Comments

Popular posts from this blog

delphi - TJvHidDeviceController "DevicePath" always showing "\" -

web applications - Making Python scripts work on MAMP -

cocoa - Converting NSString to keyCode+modifiers for AXUIElementPostKeyboardEvent -