What is the difference between String and string in C#?

Technology CommunityCategory: .NET CoreWhat is the difference between String and string in C#?
VietMX Staff asked 3 years ago

string is an alias in C# for System.String. So technically, there is no difference. It’s like int vs. System.Int32.

As far as guidelines, it’s generally recommended to use string any time you’re referring to an object.

string place = "world";

Likewise, it’s generally recommended to use String if you need to refer specifically to the class.

string greet = String.Format("Hello {0}!", place);