Like nearly all "what is the difference between X and Y", this is not a valid question (first case is one statement; and another case is a couple of statements :-)), but, fundamentally, it does have some sense.
The answer is: no functional difference at all. The result is exactly the same.
Here is the background:
System.String
, the type which can also be used via its C# alias "
string
" (what's the difference? no functional difference at all, just different text of the code :-)) is a
reference type. But it perfectly mimics the
value-type semantic, which is not a trivial feature, very non-trivial. All reference types, fundamentally, are instantiated via the constructor. There is only one
System.String
constructor; you show its use. As to the assignment of the
string literal "abc" to the string variable, you can consider it as an overloaded
assignment operator.
But things will look much more complicated if you assign the same thing to another string object. If it wasn't string, it would be two different references to the same object. In case of string, it's way, way more sophisticated. Too understand what's going on, you have to understand such advanced thing as
string intern pool. Please see:
String interning — Wikipedia, the free encyclopedia,
String.Intern Method (String) (System),
String.IsInterned Method (String) (System).
If you feel that this is a bit over your head (but better learn and understand it, just to have an idea), don't worry: in practice, there is nothing much to worry about. Only you should clearly understand more fundamental fact: strings are strictly
immutable.
—SA