In C#, the keywords for built-in types are simply aliases for corresponding types in the System namespace.
Generally, it makes no difference whether you use a keyword (such as int) or an identifier (such as Int32) to refer to a built-in type. But there’s an exception to everything, so my question in two parts is:
- When does C# require you to use, or not use, a keyword?
- When does using a keyword instead of an identifier change the meaning of the program?
A using alias directive cannot use a keyword as the type name (but can use keywords in type argument lists):
The underlying type of an enum must be specified using a keyword:
The expressions
(x)+y,(x)-y, and(x)*yare interpreted differently depending on whetherxis a keyword or an identifier: