2 using System
.Collections
.Generic
;
4 // Generics mutate tests
6 class Disposable
<T
> : IDisposable
13 interface IFoo
<TOne
,TTwo
>
19 static Func
<T
[]> For
<T
> (List
<T
> list
)
23 for (int i
= 0; i
< t
.Length
; ++i
) {
31 static Func
<T
> Throw
<T
> (T t
)
35 throw new ApplicationException (l
.ToString ());
39 static Func
<Type
> TypeOf
<T
> (T t
)
44 var e
= typeof (Disposable
<T
>);
45 e
= typeof (Disposable
<>);
46 e
= typeof (IFoo
<,>);
51 static Func
<T
> Do
<T
> (T t
)
58 } while (default (T
) != null);
64 static Func
<T
> Lock
<T
> (T t
)
76 static Func
<T
> Catch
<T
> (T t
)
81 throw new ApplicationException (l
.ToString ());
88 static Func
<T
> Finally
<T
> (T t
)
102 static Func
<T
> Using
<T
> (T t
)
105 using (var d
= new Disposable
<T
> ())
113 static Func
<T
> Switch
<T
> (T t
)
124 static Func
<List
<T
>> ForForeach
<T
> (T
[] t
)
128 return new List
<T
> () { e }
;
130 throw new ApplicationException ();
134 public void ArrayMutate
<T
> (T
[] array
)
137 Action
<int> anonMeth
= delegate (int slc
) {
138 long[] idx
= new long[] { 0, 0 }
;
139 for (int i
= 0; i
< r
; i
++) {
145 static Func
<T
[][]> ArrayMultiMutate
<T
> (T
[][] array
)
148 for (int i
= 0; i
< 3; i
++) {
149 array
[i
][i
] = default (T
);
156 public static int Main ()
158 if (For (new List
<int> { 5, 10 }
)() [1] != 10)
165 } catch (ApplicationException
)
181 var t6
= Finally (5);
185 var t7
= Using (1.1);
189 var t8
= Switch (55);
193 var t9
= ForForeach (new [] { 4, 1 }
);
197 var t10
= ArrayMultiMutate (new string [][] { new string [] { "a", "b", "c" }
, new string [] { "1", "2", "3" }
, new string [] { "A", "B", "C" }}
);
198 if (t10 () [2] [2] != null)
201 var t11
= TypeOf ("b");
202 if (t11 () != typeof (string))
205 Console
.WriteLine ("OK");