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

[求教]如何获取ArrayList中存储的值
之前的程序中使用ArrayList 存储了n组点的坐标值,也就是说ArrayList的每一项为一个长度不等的PointF[]数组,现在想把数组值取出来进行绘图,只能得到Arraylist的Object对象,如何还原得到这个PointF[]数组,使其可以直接当成点数组使用。还望各位大神指点迷津!多谢

------解决方案--------------------
Point[] Plots = _Data.Select(obj => (Point)obj).ToArray();If you leave it as an ArrayList, you can still do it using this code:

ArrayList _Data;

Point[] Plots = (from CurvePoint obj in _Data select (Point)obj).ToArray();
// 
Point[] Plots = _Data.Cast<CurvePoint>().Select(obj => (Point)obj).ToArray();
Point[] Plots = new Point[_Data.Count];
for (int i = 0; i < _Data.Count; i++)
{
Plots[i] = (Point)(CurvePoint)_Data[i];
}
------解决方案--------------------
ArraryList arr = new ArrayList();

Ponit_F[] p = arr[0] as Ponit_F[];

这就可以了啊