c# - Why is that var can only be declared and initialized in a single statement? -
why var can declared , initialized in single statement in c#?
i mean why cannot use:
var x; x = 100;
since implicit typed local variable "var" , compiler takes type right of variable assignment operator, why matter should declared , initialized in single statement?
because statement declares variable needs imply type in order compiler know var
. sure, person own intuition can logically step through code , determine type will be. compiler isn't complex human intuition. needs type defined in statement in order compile statement logically complete action.
every statement needs individually complete , compilable.
Comments
Post a Comment