As .NET doesn't use C style null
s to end a string how can I keep the allocated string but change the length of it by using unsafe code?
As I understand .NET using a 20 bytes header for every string, presumably this is where the length of the string is stored, is there anyway to directly modify this length? So .NET will keep the string in memory but when I call .Length
it'll return the .Length
I want.
if this is possible, also it would be interesting to hear all crazy possible side-effects of this
UPDATE
I'm trying accomplish this without using reflection.