クラス A があり、その中の配列の基になる型を取得しようとしています。
Class A
{
A1[] obja1;
A2[] obja2;
string x;
int i;
}
obja1 の基になるオブジェクト型を A1 として取得し、obja2 を A2 として取得するにはどうすればよいですか?ここに、私が持っているコードの一部を示します。
object AClass = myAssembly.CreateInstance("A");
PropertyInfo[] pinfos = AClass.GetType().GetProperties();
foreach(PropertyInfo pinfo in pinfos)
{
if(pinfo.PropertyType.IsArray)
{
//here get the the underlying property type so that I can do something as follows
var arr = myAssembly.CreateInstance(typeof(A1), 100);
//need to get if the array is array of A1 or A2 but do not want to hardcode
}
}
Thanks for the help..