私は2つのクラスがあります。反射と再帰 - StackOverflowExceptionが
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public bool isActif { get; set; }
public Product[] Product { get; set; }
}
public class Product
{
public string Id { get; set; }
}
そして、2つのインスタンス:
Customer Customer1 = new Customer
{
FirstName = "FirstName1",
LastName = "LastName1",
isActif = true,
Product = new Product[]
{
new Product()
{
Id = "1"
}
}
};
Customer Customer2 = new Customer
{
FirstName = "FirstName2",
LastName = "LastName2",
isActif = false,
Product = new Product[]
{
new Product()
{
Id = "2"
}
}
};
私は2つのインスタンスのすべてのプロパティを比較する一つの方法があります。
をしかし、私がプロパティProduct
に行くとき、私はStackOverflowException
を生成しました。どうして ?配列の場合はどのようにループするのですか?
EDIT:リストを使用すると、StackOverflowException
ではなく、System.Reflection.TargetParameterCountException
となります。どのようにループそれは
なぜスタックオーバーフローが発生しているのかをコードにデバッグしましたか? –
これは重複のようです。 http://stackoverflow.com/questions/3747572/how-do-i-deal-with-arrays-using-reflection –
この提案された回答は役立ちます:http://stackoverflow.com/a/4879978/6256551 –