using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
public class MyClass<T>
{
public T MainModel { get; set; }
public Type GetTheType()
{
return typeof(T).GetInterfaces().Where(i => i.IsGenericType)
.Single(i => i.GetGenericTypeDefinition() == typeof(IEnumerable<>))
.GetGenericArguments().First();
}
}
public class Test
{
public static void Main()
{
var mainInstance = new MyClass<List<string>>();
Console.Out.WriteLine(mainInstance.GetTheType().FullName);
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkxpbnE7CnVzaW5nIFN5c3RlbS5SZWZsZWN0aW9uOwoKcHVibGljIGNsYXNzIE15Q2xhc3M8VD4KewogICAgcHVibGljIFQgTWFpbk1vZGVsIHsgZ2V0OyBzZXQ7IH0KCiAgICBwdWJsaWMgVHlwZSBHZXRUaGVUeXBlKCkKICAgIHsKcmV0dXJuIHR5cGVvZihUKS5HZXRJbnRlcmZhY2VzKCkuV2hlcmUoaSA9PiBpLklzR2VuZXJpY1R5cGUpCiAgICAuU2luZ2xlKGkgPT4gaS5HZXRHZW5lcmljVHlwZURlZmluaXRpb24oKSA9PSB0eXBlb2YoSUVudW1lcmFibGU8PikpCiAgICAuR2V0R2VuZXJpY0FyZ3VtZW50cygpLkZpcnN0KCk7CiAgICB9Cn0KCnB1YmxpYyBjbGFzcyBUZXN0CnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKCXsKdmFyIG1haW5JbnN0YW5jZSA9IG5ldyBNeUNsYXNzPExpc3Q8c3RyaW5nPj4oKTsKQ29uc29sZS5PdXQuV3JpdGVMaW5lKG1haW5JbnN0YW5jZS5HZXRUaGVUeXBlKCkuRnVsbE5hbWUpOwkJCgl9Cn0=