c#中get好set中value赋值的问题,先看一段代码吧
public double Magnitude
{
get
{
return Math.Sqrt(this.SumComponentSqrs());
}
set
{
if (value < 0.0)
{
throw new ArgumentOutOfRangeException("value", value, "The magnitude of a Vector3 must be a positive value, (i.e. greater than 0)");
}
if (this == new Vector3(0.0, 0.0, 0.0))
{
throw new ArgumentException("Cannot change the magnitude of Vector3(0,0,0)", "this");
}
this = (Vector3) (this * (value / this.Magnitude));
}
这个代码的诡异之处是Magnitude自己给自己赋值了
但是,我看了2天代码,包括子程序和主程序
都没有其他外在程序给Magnitude赋值的语句
例如:object.Magnitude=x
等等诸如语句,什么都没有
难道,Magnitude能自我迭代自己?是错的吧!?
其中this 就是Vector3