2 using System.Collections;
6 public static int Main ()
8 // This is a compilation-only test.
12 // All code paths throw an exception, no need to set out parameters.
13 public static void test1 (out float f)
15 throw new NotSupportedException ();
18 // The while loop breaks but does not return, so this is ok.
19 public static void test2 (int a, out float f)
25 Console.WriteLine (a);
31 // a has been assigned in all code paths which do not return.
32 public static void test3 (long[] b, int c)
36 throw new ArgumentException ();
40 Console.WriteLine (a);
43 // Forward goto, it's ok to set f after the target label.
44 public static int test4 (int b, out float f)
48 Console.WriteLine ("Hello World");
55 Console.WriteLine (a);
62 // try { ... } catch { ... } finally { ... } block
63 static public int test5 (out float f, long d)
75 } catch (NotSupportedException e) {
77 } catch (Exception e) {
86 // Passing out parameter to method invocation
87 static public int test6 (out float f)
89 return test5 (out f, 50);
92 // Loop-variable of foreach() and for() loop.
93 static public long test7 (int[] a, int stop)
99 for (int i = 1; i < stop; i++)
105 // Initializing locals in initialize or test of for block
106 static public long test8 (int stop)
110 for (i = 1; (b = stop) > 3; i++) {
117 // Initializing locals in test of while block
118 static public long test9 (int stop)
121 while ((b = stop) > 3) {
128 // Return in subblock
129 public static void test10 (int a, out float f)
140 public static long test11 (int a)
160 // Try block which rethrows exception.
161 public static void test12 (out float f)
166 throw new NotSupportedException ();
170 // Return in subblock.
171 public static void test13 (int a, out float f)
184 // Switch block with goto case / goto default.
185 public static long test14 (int a, out float f)
210 // Forward goto, it's ok to set f before the jump.
211 public static int test15 (int b, out float f)
215 Console.WriteLine ("Hello World");
223 Console.WriteLine (a);