[System.ServiceModel] Prevent crash in Dispatcher.ListenerLoopManager… (#7136)
[mono-project.git] / mono / tests / generics-invoke-byref.2.cs
blob26088d7e30d26bddaba324b645eb3a28acd5b1dc
1 using System;
2 using System.Collections.Generic;
4 namespace TestConsole
6 class Program
8 static int Main(string[] args)
10 List<string> str = null;
12 object[] methodArgs = new object[] { str };
14 Program p = new Program();
15 p.GetType().GetMethod("TestMethod").Invoke(p, methodArgs);
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;
28 a [0] = null;
29 typeof (Program).GetMethod ("TestMethodNullable").Invoke (p, a);
30 if ((int)a [0] != 0)
31 return 3;
33 return 0;
36 public Program()
40 public void TestMethod(ref List<string> strArg)
42 strArg = new List<string>();
45 public void TestMethodNullable (ref int? x) {
46 if (x != null)
47 x ++;
48 else
49 x = 0;