Executing Managed Code

Now that you know how types can be built and how IL code and metadata can be generated, either at compile time or at runtime, we should take a closer look at the execution model for managed code.

Consider the following fragment of C# code, which implements and uses a simple Calculator class. If the language constructs used here look foreign to you, don’t worry; we cover the syntax and meaning of C# programs extensively throughout the book:

using System;static class Program{    static void Main()    {        var random = new Random();        int a = random.Next();        int b = random.Next();        var calc = new Calculator();        int sum = calc.Add(a, b);        Console.WriteLine("{0} ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.