cleol
[mcs.git] / tests / gtest-421.cs
blob3ffa5a960c4091f0f6773cb63caa4fd573c00db9
1 using System;
3 public class OneOff
5 public static int Main ()
7 double[] darray = { 1.0, 2.0, 3.0 };
8 double[] clone = OneOff.Clone (darray);
9 Console.WriteLine (clone.Length);
10 return clone.Length == 3 ? 0 : 1;
13 private static T[] Clone<T> (T[] o)
15 if (o == null)
16 return null;
17 Type t = typeof (T);
18 if (t.IsValueType)
19 return (T[]) o.Clone ();
20 else if (t.IsArray && (t.GetElementType ().IsValueType || t.GetElementType () == typeof (string))) {
21 T[] copy = new T[o.Length];
22 for (int i = 0; i < o.Length; i++)
23 copy[i] = (T) (o[i] as Array).Clone ();
24 return copy;
25 } else
26 throw new ArgumentException ("oops");