What if you do this:
class var { public static implicit operator var(int value) { return new var(); } } var myVar = 5;
myVar will be of type var , not type int .
( operator added, so there is an implicit conversion from int to var ).
This rule was inserted because var not a reserved keyword in C # (and still not ... If you look here you will see this "context keyword"), so the / struct / enum class named var was valid in C # 2.0
If the type named var is in scope: if there is a class / struct / enum named var that is in scope (so that it is "reachable" by simply writing var without using the namespace)
then the var keyword will resolve this type name: then var means "your custom type" and not "var keyword"
xanatos
source share