[configure] Add new target.
[mono-project.git] / mcs / tests / gtest-483.cs
blobba8a361a7ef51199201c7243708fae7562b14c88
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
5 class Program
7 public static int Main ()
9 Int32Collection src = new Int32Collection ();
10 Int32Collection dest = new Int32Collection ();
12 src.Add (5);
13 src.Add (7);
14 dest.Add (4);
16 ReplaceContentsWith<Int32Collection> (src, dest);
18 if (dest.Count != 2)
19 return 1;
20 if (dest[0] != 5)
21 return 2;
22 if (dest[1] != 7)
23 return 3;
25 return 0;
28 private static void ReplaceContentsWith<T> (T src, T dst)
29 where T : Int32Collection
31 dst.Clear ();
32 foreach (int value in src)
33 dst.Add (value);
37 class Int32Collection : IEnumerable
39 List<int> list = new List<int> ();
41 public int Count
43 get { return list.Count; }
46 public int this[int index]
48 get { return (int) list[index]; }
49 set { list[index] = value; }
52 public void Add (int value)
54 list.Add (value);
57 public void Clear ()
59 list.Clear ();
62 IEnumerator IEnumerable.GetEnumerator ()
64 return list.GetEnumerator ();