Are you saying that you could exactly replicate a C# System.String using IL, or am I mis-understanding?
BTW there is a typo: "passed in my the calling code" should probably be "passed in by the calling code".
I wonder if the new C# 6 string interpolation also uses string builder like format does. e.g.
$"Name = {name}, hours = {hours:hh}"
https://msdn.microsoft.com/en-us/library/Dn961160.aspxThis post seems to suggest it uses concatenation, which may be bad for performance in some situations due to the immutability.
https://weblogs.asp.net/bleroy/c-6-string-interpolation-is-n...
> BTW there is a typo: "passed in my the calling code" should probably be "passed in by the calling code".
Thanks for spotting that, I'll fix it in a bit
However, at the instruction level you can do some pretty awesome stuff. This slice[1] library is able to verifiably and safely grab a slice of data out of any arbitrary structure by using a MSIL feature that was invented for C++/CLR. The call site[2] is not unsafe.
[1]: https://github.com/joeduffy/slice.net/blob/master/src/PtrUti... [2]: https://github.com/joeduffy/slice.net/blob/master/src/Slice....
[1]: https://github.com/dotnet/corefxlab/tree/master/src/System.S...
There are many things that aren't possible in C# but can be expressed in pure IL. Sigil [0] is an IL generator used in the high-performance JSON serializer Jil [1], which takes advantage of this.
https://github.com/kevin-montrose/Sigil
https://github.com/kevin-montrose/Jil