ISourceCode

Make the frequent cases fast and the rare case correct

C# – when to use .NET framework class library (FCL) type vs an alias

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.

One response to “C# – when to use .NET framework class library (FCL) type vs an alias

  1. abdul November 28, 2012 at 12:16 pm

    its containes all libraries required to excute .net programme…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: