Why does the first line compile and the second not?
string var = "123";
var string = "123";
I mean string and var should be both keywords..
Why does the first line compile and the second not?
string var = "123";
var string = "123";
I mean string and var should be both keywords..
var is a contextual keyword, whereas string is not.
Contextual keywords are
used to provide a specific meaning in the code, but it is not a reserved word in C#.
This is why you can use var as a variable name.
Presumably, this is for backwards compatibility. If var were introduced as a proper keyword, old code that uses var as a variable name would break.