Question

How can I clear all interned strings in linqpad?

Looking at this example :

//var asd="asd";
string s = new string(new  []{'a','s','d'});
Console.WriteLine (string.IsInterned(s));

It always return null , which is fine.

But once I un-remark the first line it always yield "asd" even if I remark it again.

It seems that the only solution is to close the program and start it again.

p.s. : in visual studio it's always returns the desired results (console mode).

Était-ce utile?

La solution

LINQPad maintains the AppDomain between runs, so everything that's static will remain in memory. You can change this behavior by going to Edit > Preferences > Advanced > Always use fresh application domains.

While the above is true, it seems string interning is performed at a process level (see here). So there's no way to reset that besides restarting.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top