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

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -