2 using System
.Reflection
;
6 public struct SimpleStruct
{
10 public SimpleStruct (bool arg
) {
16 static void Test2 () {
17 Console
.WriteLine ("Test2 called");
20 public static SimpleStruct
Test1 (SimpleStruct ss
) {
21 Console
.WriteLine ("Test1 called " + ss
.a
+ " " + ss
.b
);
22 SimpleStruct res
= new SimpleStruct ();
28 public static void Foo(ref int x
, ref int y
)
35 Type t
= typeof (Test
);
37 MethodInfo m2
= t
.GetMethod ("Test2");
41 MethodInfo m1
= t
.GetMethod ("Test1");
45 object [] args
= new object [1];
46 SimpleStruct ss
= new SimpleStruct ();
51 SimpleStruct res
= (SimpleStruct
)m1
.Invoke (null, args
);
58 // Test that the objects for byref valuetype arguments are
59 // automatically created
60 MethodInfo m3
= typeof(Test
).GetMethod("Foo");
64 m3
.Invoke(null, args
);
66 if ((((int)(args
[0])) != 20) || (((int)(args
[1])) != 30))
69 // Test the return value from ConstructorInfo.Invoke when a precreated
71 ConstructorInfo ci
= typeof (SimpleStruct
).GetConstructor (new Type
[] { typeof (bool) }
);
72 SimpleStruct res2
= (SimpleStruct
)ci
.Invoke (ss
, new object [] { false }
);