ジェネリック型のすべてのパブリックプロパティを初期化したい。
私は次のメソッドを書きました:
public static void EmptyModel<T>(ref T model) where T : new()
{
foreach (PropertyInfo property in typeof(T).GetProperties())
{
Type myType = property.GetType().MakeGenericType();
property.SetValue(Activator.CreateInstance(myType));//Compile error
}
}
しかし、コンパイルエラーがあります
どうすればいいですか?