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).

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top