Difference between string and String in C#

string is an alias in C# for System.String. So technically, there is no difference. It’s like int vs. System.Int32.You can use whichever you prefer, although I generally use string when I’m planning on using it much like a primitive data type (similar to int, float, or bool) and String when I’m planning on using it as an object/class.

Example:-

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

Leave a Reply

Your email address will not be published. Required fields are marked *