Difference between string and String in C#

Most of the time we get confused about the string and String class in C#.

Technically, there is no difference between string and String.

string is the Alias for the System.String class. It is just a coding guideline. Microsoft recommended coding style says that, use the string whenever we are creating object of string data type and use String class whenever we want to access the functions of the string class.

Example:

string foo = "world";
string bar = String.Format("Hello {0}!", foo);


 

Advertisements

#string-and-string