Is ToString() optimized by compiler?
Posted
by TheVillageIdiot
on Stack Overflow
See other posts from Stack Overflow
or by TheVillageIdiot
Published on 2010-05-31T04:28:11Z
Indexed on
2010/05/31
4:32 UTC
Read the original article
Hit count: 290
Suppose I've following Code:
Console.WriteLine("Value1: " + SomeEnum.Value1.ToString() + "\r\nValue2: " +
SomeOtherEnum.Value2.ToString());
Will Compiler Optimize this to:
Console.WriteLine("Value1: " + SomeEnum.Value1 + "\r\nValue2: " +
SomeOtherEnum.Value2);
I've checked it with IL Disassembler and there are calls to
IL_005a: callvirt instance string [mscorlib]System.Object::ToString()
I don't know if JIT optimizes this.
© Stack Overflow or respective owner