属性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 –