Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / generics-invoke-byref.2.cs
1 using System;
2 using System.Collections.Generic;
3
4 namespace TestConsole
5 {
6     class Program
7     {
8         static int Main(string[] args)
9         {
10                         List<string> str = null;
11           
12                         object[] methodArgs = new object[] { str };
13           
14                         Program p = new Program();
15                         p.GetType().GetMethod("TestMethod").Invoke(p, methodArgs);
16
17                         /* Byref nullable tests */
18                         object[] a = new object [1];
19                         int? i = 5;
20                         object o = i;
21                         a [0] = o;
22                         typeof (Program).GetMethod ("TestMethodNullable").Invoke (p, a);
23                         if ((int)a [0] != 6)
24                                 return 1;
25                         if ((int)o != 5)
26                                 return 2;
27
28                         a [0] = null;
29                         typeof (Program).GetMethod ("TestMethodNullable").Invoke (p, a);
30                         if ((int)a [0] != 0)
31                                 return 3;
32
33                         return 0;
34         }
35       
36                 public Program()
37                 {
38                 }
39
40         public void TestMethod(ref List<string> strArg)
41         {
42           strArg = new List<string>();
43         }
44
45                 public void TestMethodNullable (ref int? x) {
46                         if (x != null)
47                                 x ++;
48                         else
49                                 x = 0;
50                 }
51     }
52 }