Example (note the case):
string s = "Hello world!";
String s = "Hello world!";
What are the guidelines for the use of each? And what are the differences?
.netaliasc++stringtypes
Example (note the case):
string s = "Hello world!";
String s = "Hello world!";
What are the guidelines for the use of each? And what are the differences?
Best Solution
stringis an alias in C# forSystem.String.So technically, there is no difference. It's like
intvs.System.Int32.As far as guidelines, it's generally recommended to use
stringany time you're referring to an object.e.g.
Likewise, I think it's generally recommended to use
Stringif you need to refer specifically to the class.e.g.
This is the style that Microsoft tends to use in their examples.
It appears that the guidance in this area may have changed, as StyleCop now enforces the use of the C# specific aliases.