0
我很難將整數分配給點類。我有一個包含X
和Y
值(分別爲Xp
和Yp
)的整數的座標類列表。整數型是Int32
和從使用string
到double
然後到達integer
轉化:從被分配給一個點之前的各座標中扣除c#給點分配值的問題
X = double.Parse(setX, System.Globalization.CultureInfo.InvariantCulture);
最小X
和Y
列表中的值。一張支票顯示計算正確執行,但在數值上都是錯誤的。我在想,如果我使用points[n]
進行分配的方式是否存在問題,或者是否有更好的方法來創建要繪製爲多邊形的點?對不起,這是一個相當長的生產coords類的過程程序,所以我省略了它,但如果您需要更多信息,請告訴我。
Point[] points = new Point[coords.Count];
int n = 0;
foreach (var i in coords)
{
//These calculations are working fine:
int Xp = i.Xplt - minX;
int Yp = i.Yplt - minY;
//However when I assign to a new point. The calculation is wrong returning 0's and the incorrect result
points[n] = new Point(Xp, Yp);
n = +1;
}
哎呀我無法相信我錯過了你的回答但由於 – alkey