JAL Computing
|
Static Method and FieldCIL code from a simple class with a single static readonly string field and static DoIt method. C# Source Codeusing System; namespace TestILStatic { /// <summary> /// Summary description for Class1. /// </summary> class Class1 { static readonly string message= "Hello World!"; static void DoIt() { System.Console.WriteLine(message); } /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { // // TODO: Add code to start application here // Class1.DoIt(); //System.Console.ReadLine(); } } }
Common Intermediate Language Code.class private auto ansi beforefieldinit.class private auto ansi beforefieldinit Class1 extends [mscorlib]System.Object { } // end of class Class1 message : private static initonly string.field private static initonly string message .cctor : void().method private hidebysig specialname rtspecialname static void .cctor() cil managed { // Code size 11 (0xb) .maxstack 1 IL_0000: ldstr "Hello World!" IL_0005: stsfld string TestILStatic.Class1::message IL_000a: ret } // end of method Class1::.cctor .ctor : void().method public hidebysig specialname rtspecialname instance void .ctor() cil managed { // Code size 7 (0x7) .maxstack 1 IL_0000: ldarg.0 IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0006: ret } // end of method Class1::.ctor DoIt : void().method private hidebysig static void DoIt() cil managed { // Code size 11 (0xb) .maxstack 1 IL_0000: ldsfld string TestILStatic.Class1::message IL_0005: call void [mscorlib]System.Console::WriteLine(string) IL_000a: ret } // end of method Class1::DoIt Main : void(string[]).method private hidebysig static void Main(string[] args) cil managed { .entrypoint .custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 ) // Code size 7 (0x7) .maxstack 0 IL_0000: call void TestILStatic.Class1::DoIt() IL_0005: nop IL_0006: ret } // end of method Class1::Main |
Send mail to [email protected]
with questions or comments about this web site. Copyright © 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2008, 2009 ©
|