using System.Collections.Generic;
public static T Convert<T>(int[] src)
Type genericClassType = typeof(T);
Type[] typeParameters = genericClassType.GetGenericArguments();
Type genericTypeDef = genericClassType.GetGenericTypeDefinition();
Type constructedClass = genericTypeDef.MakeGenericType(typeParameters);
T arrayLike = (T)Activator.CreateInstance(constructedClass, src);
public static void Main()
Stack<int> copy = Convert<Stack<int>>(src);
Queue<int> copy2 = Convert<Queue<int>>(src);
List<int> copy3 = Convert<List<int>>(src);
Console.WriteLine(string.Join(",", copy.ToArray()));
Console.WriteLine(string.Join(",", copy2.ToArray()));
Console.WriteLine(string.Join(",", copy3.ToArray()));