转换

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace alltest
{
    class Program
    {
        static void Main(string[] args)
        {
            object ob = 5;
            int obint = Convert.ToInt32(ob);

            int obint2 = (int)ob;
            int obint3 =int.Parse(ob.ToString());


            object ob2 = true;
            int ob2int1 = Convert.ToInt32(ob2);
            int ob2int2 = (int)ob2;

        }
    }
}

.method private hidebysig static void Main(string[] args) cil managed
            {
            .entrypoint
            .maxstack 1
            .locals init (
            [0] object ob,
            [1] int32 obint,
            [2] int32 obint2,
            [3] int32 obint3,
            [4] object ob2,
            [5] int32 ob2int1,
            [6] int32 ob2int2)
            L_0000: nop
            L_0001: ldc.i4.5
            L_0002: box int32
            L_0007: stloc.0
            L_0008: ldloc.0
            L_0009: call int32 [mscorlib]System.Convert::ToInt32(object)
            L_000e: stloc.1
            L_000f: ldloc.0
            L_0010: unbox.any int32
            L_0015: stloc.2
            L_0016: ldloc.0
            L_0017: callvirt instance string [mscorlib]System.Object::ToString()
            L_001c: call int32 [mscorlib]System.Int32::Parse(string)
            L_0021: stloc.3
            L_0022: ldc.i4.1
            L_0023: box bool
            L_0028: stloc.s ob2
            L_002a: ldloc.s ob2
            L_002c: call int32 [mscorlib]System.Convert::ToInt32(object)
            L_0031: stloc.s ob2int1
            L_0033: ldloc.s ob2
            L_0035: unbox.any int32
            L_003a: stloc.s ob2int2
            L_003c: ret
            }
            

            

原文地址:https://www.cnblogs.com/lsfv/p/1455606.html