Reputation: 20050
Consider the following code:
private bool flag;
private void Test()
{
Console.WriteLine(flag.ToString());
}
Suppose that Test() is called multiple times, will it allocate memory every time, or is there some mechanism in C# (compiler or runtime) that optimizes this ?
I've heard of "String interning", but i am not sure if it's performed for scenarios such as this one, or only when string constants are involved.
Upvotes: 0
Views: 479