C# & CLR Internals (50 Qs)•Part 1: Core Language, CLR & Memory Architecture (1 - 10)
What are String Interning and `StringBuilder` internals?
senior LevelSystem Design
In Simple Words:
- String Immutability: Modifying a string creates a new string on the heap.
- String Interning: The CLR maintains an internal hash table (intern pool) of unique string literals to reuse identical strings across the AppDomain.
StringBuilder: A mutable buffer backed by an array ofchar[]. Instead of allocating new strings on every concatenation, it appends into its internal buffer, dynamically chaining chunks when capacity is exceeded.