class Test { static private int scaleFactor = 1; static public int ScaleFactor { get { return scaleFactor; } set { if (value == 0) { scaleFactor = scaleFactor == 1 ? -1 : 1; } else scaleFactor = value; } } static void Main(string[] args) { //--ScaleFactor; int i = --ScaleFactor; Console.WriteLine(i); Console.ReadLine(); } }Ild output of main()
.method private hidebysig static void Main(string[] args) cil managed { .entrypoint // Code size 27 (0x1b) .maxstack 2 .locals init ([0] int32 i) IL_0000: call int32 Test::get_ScaleFactor() >>>>>> get value of ScaleFactor [ 1 ] IL_0005: ldc.i4.1 >>>>>>>>> load constant 1 on the stack [ 1 1 ] IL_0006: sub >>>>>>>>>>> subtract constant 1 [ 0 ] IL_0007: dup >>>>>>>>>>> duplicate the top value of the stack [ 0 0 ] IL_0008: call void Test::set_ScaleFactor(int32) >>>>>>>>>>> call the Set [ 0 ] IL_000d: stloc.0 >>>>>>>>>> store in i [ ] IL_000e: ldloc.0 >>>>>>>>>>> push i on top of the Stack [ 0 ] IL_000f: call void [mscorlib]System.Console::WriteLine(int32) >>>>>>> call WriteLIne IL_0014: call string [mscorlib]System.Console::ReadLine() IL_0019: pop IL_001a: ret } // end of method Test::Main