From this question I learned that the nameof()
operator, introduced in C# 6.0, does not work on synonymous. So you can write nameof(System.Object)
but not nameof(object)
.
Now, there are 2 other similar operators, typeof()
and default()
, and they work perfectly on synonymous. You can write:
default(object);
default(int);
typeof(string);
typeof(long);
as well as:
default(Object);
default(Int32);
typeof(String);
typeof(Int64);
and the results are the same.
I guess that it would have been possible to build the nameof()
operator to operate with synonymous too.
So the question is: WHY it was not implemented to work with object
, string
, int
, etc.? Is my guess wrong (i.e. it's impossible to implement)? Or was it a design choice?