Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC#string interning and poolingSingle-choice MCQ

Compile-time string literals are automatically interned, but strings built at runtime are not. What does this snippet print and why?

string a = "hello"; string part = "hel"; string runtime = part + "lo"; // built at runtime Console.WriteLine(ReferenceEquals(a, runtime)); Console.WriteLine(ReferenceEquals(a, string.Intern(runtime)));