In this post I discuss what is the difference between String and string in C#? (notice the case). What are the guidelines for the use of each? And what are the differences?
What is String and string?
string is an alias for System.String. So technically, there is no difference. It’s like int vs. System.Int32.
About using the provided type aliases in C#, Jeffrey Richter quoted in his book CLR Via C#
I’ve seen a number of developers confused, not knowing whether to use string or String in their code. Because in C# the string (a keyword) maps exactly to System.String (an FCL type), there is no difference and either can be used.
I think it’s generally recommended to use String if you need to refer specifically to the class.
String is a reserved word, but String is just a class name. This means that ‘string’ cannot be used as a variable name by itself.
If for some reason you wanted a variable called string, you’d see only the first of these compiles: