以下のコードでは、StylusPointCollection (SPC) は、StylusPoint 変数をメソッドの内部で宣言するか外部で宣言するかによって (つまり、内部定義をコメント化し、コメント化された行のコメントを解除した場合) 変更されます。これがなぜなのかわかりません。
//StylusPoint spXY;
private void DrawBinaryTree(int depth, StylusPoint pt, double length, double theta)
{
if (depth > 0)
{
StylusPoint spXY = new StylusPoint(pt.X + length * Math.Cos(theta) * Math.Cos(a), pt.Y + length * Math.Sin(theta) * Math.Sin(a));
//spXY = new StylusPoint(pt.X + length * Math.Cos(theta) * Math.Cos(a), pt.Y + length * Math.Sin(theta) * Math.Sin(a));
SPC.Add(pt);
SPC.Add(spXY);
DrawBinaryTree(depth - 1, spXY, length * lengthScale, theta + deltaTheta);
DrawBinaryTree(depth - 1, spXY, length * lengthScale, theta - deltaTheta);
}
}
LinqPad を使用して、より単純な例を考え出そうとしましたが、失敗しました。