Difference between string in String in C#

If you are new to C#, you might wonder what’s the difference between String(with capital S) and string (with small s) in C#.

string(with small s) is a keyword in C# which represents the System.String type in Common Type System whereas the String (with capital S) is the shorthand notation for System.String.  Consider the following code snippet where we declare couple of variables using ‘string’ and ‘String’. When we probe the type of the variables, both says they are of type ‘System.String’

 

If you notice, string (with small s) is in blue color as all keywords( such as static, void, class etc..) in C# will be in blue color. If you are using VB.Net, you can refer the same System.String type using VB.Net keyword ‘String’(string with capital S).

 

So, string(with small s) is a C# keyword for representing the type System.String.

Any queries? Please let me know your thoughts in the comments.


Posted

in

by

Tags: