This project is read-only.

Simplification of type names when accessing static members

Topics: C# Language Design, General
Apr 12, 2014 at 2:15 PM
New Code Analysis suggests accessing static members of primitive types using their keyword synonyms instead of the type itself. For example: use string.IsNullOrEmpty instead of String.IsNullOrEmpty; or int.Parse instead of Int32.Parse. In my opinion, this simplification introduces inconsistency, because:
  • Keywords do not have members, rather have types (classes and structs)
  • Keywords are synonyms for real types, so they are not simpler forms
I think synonyms for primitive types are good when you use them as "types", but not when accessing their members.
Apr 13, 2014 at 7:28 PM
No, keywords do not have members.

But according to the documentation:
The string type represents a sequence of zero or more Unicode characters. string is an alias for String in the .NET Framework.
So the string keyword stands for something like:
using string = System.String;
string.IsNullOrEmpty is, like you propose, using string as a type. An types have members.
Marked as answer by marstr on 4/16/2014 at 5:33 PM