String.Intern , ; String.IsInterned .
IsInterned("PK") "PK", . , bool, , ( , ). , - , bool:
public static bool IsInternedBool(string text)
{
return string.IsInterned(text) != null;
}
, , , : GetInterned ?
, : , :
using System;
class Test
{
static void Main()
{
string first = new string(new[] {'x'});
string second = new string(new[] {'y'});
string.Intern(first);
Console.WriteLine(string.IsInterned(first) != null);
string.IsInterned(second);
Console.WriteLine(string.IsInterned(second) != null);
}
}