What’s the difference between String and string

Most of the new developers will have this question and confusion if they need to use as string or String. To answer in simple, there is no difference between String and string. Both are same. a string is an alias in C# for System.String.

When declaring the variable of type string you can declare in both the ways as shown below and it doesn’t impact the performance in anyway. As told above string is an alias and String is a class. Many developers prefer to use as string as its a C# type alias. Finally, both are compiled to System.String in IL(Intermediate Language)

Code Snippet to find Difference between String and string

You may also like...

Leave a Reply

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