日期:2014-05-17  浏览次数:20794 次

【求助】如何定义长度不定 的数组?
各位大佬,
我想用GUI+下面的graphics.DrawClosedCurve(Pen, PointF []) 函数画个封闭曲线,但是我不知道PointF[]这个数组的长度,必须在运行的时候才知道长度。
这个数组怎么定义?
可变长度的数组 DrawClosedCurve

------解决方案--------------------
引用:
引用:其实可以用
 List<PointF> lpf = new List<PointF>();

斑竹,我现在写代码的时候用的是List,但问题是画不出来。
问题是graphics.DrawClosedCurve(Pen, PointF []) 参数只有 PointF [] 这一种

List<PointF> lpf = new List<PointF>();
lpf.Add(........);
g.DrawClosedCurve(pen, lpf.Select(x => new PointF(x.X, x.Y)).ToArray());
------解决方案--------------------
ArrayList List = new ArrayList();
for( int i=0;i<10;i++ ) //给数组增加10个Int元素
         List.Add(i); 
Int32[] values = (Int32[])List.ToArray(typeof(Int32));//返回ArrayList包含的数组