Does ldstr internally implement newobj?
.net, c#, cil, il, jit
Solution
`ldstr` gives you the reference to the literal string as per the documentation (remember literal strings are interned per default, so they are only created once). The first statement creates a regular instance of `string` using the `newobj` instruction as expected.
Problem
As we all know strings are implicitly instantiated, meaning that we don't have to use `new` in order to get a reference to an object of one. Because of this it was always my belief that the framework is taking care of this, and hence I would get identical IL if I did something like this: ``` String first = new String(new char[] {'a'}); string second = "a"; ``` However it appears that the first line is done using `newobj instance void [mscorlib]System.String::.ctor(char[])` and the second `ldstr "a"`. So in order to obtain a string reference, does `ldstr` internally call `newobj` and where can I see the specification / details to back this up?