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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -