11 July 2012

String vs string in c#

String vs string in C#

we use either the keyword string or  String .

Is both String and string same in C# ?

string is just an alias name for the class System.String which means both has the same functionality.
The IL code generated for both of them is also same .
Note that string is a keyword , but String isn’t which lets you create an variable with the name String like


Another interesting thing is we can also declare variable name as String

 String String = "Arun Prakash";
 MessageBox.Show(String);


 If you declare the variable name as string, Error occured

 String string = " Arun Prakash";
 MessageBox.Show(string);







No comments:

Post a Comment

Comments Welcome