Why doesn't C# let you declare multiple variables using var?
-
07-11-2019 - |
题
Given the following:
// not a problem
int i = 2, j = 3;
so it surprises me that this:
// compiler error: Implicitly-typed local variables cannot have multiple declarators
var i = 2, j = 3;
doesn't compile. Maybe there is something I don't understand about this (which is why I'm asking this)?
But why wouldn't the compiler realize that I meant:
var i = 2;
var j = 3;
which WOULD compile.
没有正确的解决方案
不隶属于 StackOverflow