O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hello LCG

The LCG Hello World example is shown here, simply printing “Hello LCG!” to the screen based on a dynamically generated assembly:

// An assembly...var asm = AppDomain.CurrentDomain.DefineDynamicAssembly(    new AssemblyName("LCGDemo"),    AssemblyBuilderAccess.Run);// ...contains a module...var mod = asm.DefineDynamicModule("MyModule");// ...contains a type...var tpe = mod.DefineType("Sample");// ...contains a method...var mtd = tpe.DefineMethod("SayHello",                           MethodAttributes.Public | MethodAttributes.Static);// ...contains a code body...var gen = mtd.GetILGenerator();gen.Emit(OpCodes.Ldstr, "Hello LCG!");                    // The mythical infoof(Console.WriteLine(string))gen.Emit(OpCodes.Call, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required