これは私のジェネリッククラスです:
public class MyClass<T>
{
public T MainModel { get; set; }
public Type GetType()
{
//here
}
}
それから私はそれをこの形で使います:
List<MySecondClass> Myinstance = new List<MySecondClass>();
MyClass<IEnumerable<MySecondClass>> mainInstance = new MyClass<IEnumerable<MySecondClass>> { MainModel = Myinstance };
だから私はあなたの提案が何であるかをGetType()
返すメソッドが必要ですか?typeof(MySecondClass)
アップデート
私は常に2つの形式で使用することを言及しなければなりませんMyClass
:最初:私は上で正確にコーディングしましたそして2番目:
ThirdClass thirdone = new ThirdClass();
MyClass<ThirdClass> = new MyClass<ThirdClass>(){ MainModel = thirdone};