Global Methods
Global methods, similar to global fields, are defined outside any class scope. Most of the features of global fields and global methods are also similar: global methods are all static, and the accessibility flags for both mean the same.
Of course, one global method worth a special mention is the global class constructor, .cctor. As the preceding chapter discussed, a global .cctor is the best way to initialize global fields. The following code snippet from the sample file Gcctor.il on the companion CD provides an example:
.field private static string Hello .method private static void .cctor( ) { ldstr "Hi there! What's up?" stsfld string Hello ret} .method public static void Exec( ) { .entrypoint ldsfld string Hello // Global fields are accessible // within the module call void [mscorlib]System.Console::WriteLine(string) ret }