屬性getter和setter方法是這樣實現的方法(get_X和set_X)。
在投影設置程序中寫入Projection = value
,導致set_Projection()
內的set_Projection()
遞歸調用。 (這同樣適用於get_Projection()
。)
由於圍繞呼叫沒有條件,遞歸是無限的。
至於public T PropA { get; set; }
,它是糖語法:
private T _PropA;
public T PropA
{
get
{
return _PropA;
}
set
{
_PropA = value;
}
}
你應該做的是:
private Matrix _projection;
public Matrix Projection
{
get
{
return _projection;
}
protected set
{
// Make sure that Matrix is a structure and not a class
// override == and != operators in Matrix (and Equals and GetHashCode)
// If Matrix has to be a class, use !_project.Equals(value) instead
// Consider using an inaccurate compare here instead of == or Equals
// so that calculation inaccuracies won't require recalculation
if (_projection != value)
{
_projection = value;
generateFrustum();
}
}
}
更多詳細資料請...添加堆棧跟蹤和代碼 – eyossi
它的其餘部分是遞歸調用,投影調用投影。使用私人領域。魯本的答案會奏效。 – Shyju
僅供參考,generateFrustum()應根據.NET指南命名爲GenerateFrustum():http://msdn.microsoft.com/en-us/library/ms229002.aspx –