Example ( Look at the case ):
string s = "Hello world!"; String s = "Hello world!";
What are the guidelines for using each? And what are the differences?
string
is a C# alias for System.String
.
So technically, there is no difference. It's like int
vs. System.Int32
As for guidelines, it's generally recommended to use string
whenever you refer to an object.
e.g
string place = "world";
Similarly, I think using String
is generally recommended if you need to refer specifically to the class.
e.g
string greet = String.Format("Hello {0}!", place);
It appears that guidance in this area may have changed, as StyleCop now requires the use of C#-specific aliases.