What are the differences between these two, and which one should I use?
string s = "Hello world!"; String s = "Hello world!";
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.