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

Consistency level in Azure cosmos db

 Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...