2 // This test tests both how arguments are selected in the presence
3 // of ref/out modifiers and the params arguments.
7 public struct FancyInt
{
10 public FancyInt (int v
)
20 public static void Foo (ref int i
, ref int j
)
25 public static int Bar (int j
, params int [] args
)
30 foreach (int i
in args
){
31 Console
.WriteLine ("My argument: " + i
);
38 public static void Foo (int i
, int j
)
43 static void In (ref int a
)
48 static void Out (ref int a
)
53 static int AddArray (params int [] valores
)
57 for (int i
= 0; i
< valores
.Length
; i
++)
63 static int AddFancy (params FancyInt
[] vals
)
67 for (int i
= 0; i
< vals
.Length
; i
++)
68 total
+= vals
[i
].value;
74 public static int Main ()
79 int [] arr
= new int [2] { 0, 1 }
;
89 if (Bar (i
, j
, 5, 4, 3, 3, 2) != 19)
92 //if (Bar (1, arr) != 1)
104 int [] arr2
= new int [2] {1, 2}
;
106 if (AddArray (arr2
) != 3)
109 FancyInt f_one
= new FancyInt (1);
110 FancyInt f_two
= new FancyInt (2);
112 if (AddFancy (f_one
) != 1)
115 if (AddFancy (f_one
, f_two
) != 3)
118 Console
.WriteLine ("Test passes");