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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.