Will this increase performance since the compiler needs to do less operation?
No. I do not think so.
I believe that you can check your IL code using any decompiler, you will see the same things.
The first code is IL,
.locals init ([0] class _1.RarelyCalledClass orarelyCalled) IL_0000: nop IL_0001: newobj instance void _1.RarelyCalledClass::.ctor() IL_0006: stloc.0 IL_0007: ldloc.0 IL_0008: callvirt instance void _1.RarelyCalledClass::rarelyCalledMethod() IL_000d: nop IL_000e: ret
Second IL code,
.maxstack 8 IL_0000: nop IL_0001: newobj instance void _1.RarelyCalledClass::.ctor() IL_0006: call instance void _1.RarelyCalledClass::rarelyCalledMethod() IL_000b: nop IL_000c: ret
Based on this structure,
static void Main(string[] args) {
The only difference is this: your first code uses stloc nad ldloc for stack problems, the second not.
source share