Пример #1
0
 private static void Demo2()
 {
     // Force the code in the finally to be eagerly prepared
     RuntimeHelpers.PrepareConstrainedRegions();
     try {
         Console.WriteLine("In try");
     } finally {
         // Type2’s static constructor is implicitly called in here
         Type2.M();
     }
 }
Пример #2
0
 private static void Demo2()
 {
     Console.WriteLine("In Demo2");
     // Force the code in the finally to be eagerly prepared
     RuntimeHelpers.PrepareConstrainedRegions(); // In the System.Runtime.CompilerServices namespace
     try {
         Console.WriteLine("In try");
     }
     finally {
         // Type2’s static constructor is implicitly called in here
         Type2.M();
     }
 }
Пример #3
0
 private static void Demo2()
 {
     Console.WriteLine("In Demo2");
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         Console.WriteLine("In try");
     }
     finally
     {
         Type2.M();
     }
 }