In C# if we want to create a variable of type string we can use:
string str="samplestring"; // this will allocate the space to hold the string
In C#, string is a class type, so if we want to create an object, normally we have to use the new keyword. So how is allocation happening without new or constructors?
This is simply the C# compiler giving you a shortcut by allowing string literals.
If you’d rather, you can instantiate a string by any number of different constructors. For example: