- 488,135 hits
Make the frequent cases fast and the rare case correct
C# – when to use .NET framework class library (FCL) type vs an alias
February 8, 2012Posted by on
I started to wonder if i should use string keyword which is an alias of System.String or String class name while coding in C# and after reading the three posts of stackoverflow 1 , 2 and 3 I have decided to follow the conventions suggested by this blogger
The blogger says “In my case I use string when I think of it as a simple type, just like I do with int, char, byte etc. Simple types aren’t classes/objects tho, so when I decide to use a method declared in the underlaying .NET Framework type in C# I use the class name, that is String, Integer, Char, Byte etc. Hence I use “string” in declarations and “String” when using the static methods and properties, like “String.IsNullOrEmpty(string)” or “String.Empty”.
Although both generate the same intermediate language.