using System.Collections.Generic;
public static void Main()
var originalList = new List<string>();
var dupedList = DoopList(originalList);
System.Console.WriteLine("Returned: " + dupedList.GetType());
bool match = originalList.GetType() == dupedList.GetType();
System.Console.WriteLine("Types match? " + match);
TestObject o = new TestObject();
PropertyInfo[] props = o.GetType().GetProperties();
foreach(PropertyInfo prop in props)
Console.WriteLine("Prop:" + prop.Name);
public static dynamic DoopList(dynamic collection)
Type collectionType = collection.GetType();
Type[] args = collectionType.GetGenericArguments();
System.Console.WriteLine("Generic arguments:");
System.Console.WriteLine(" " + a.ToString());
Type listType = typeof(List<>).MakeGenericType(args);
System.Console.WriteLine("List type: " + listType.ToString());
if(collectionType == listType)
return Activator.CreateInstance(listType);
public class TestObject {
public List<string> MyProp {get; set;}