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

解决方案 »

  1.   

    // 定义
    PointF[] pts;
    // 使用
    pts = new PointF[count];
      

  2.   

    http://msdn.microsoft.com/zh-cn/library/w5zay9db(v=vs.80).aspx
      

  3.   


    高人,你说的是这个意思么?貌似不行呀
    int[] arr=new int[params]();
      

  4.   

    其实可以用
     List<PointF> lpf = new List<PointF>();
      

  5.   


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

  6.   

     List<PointF> list;
     var ary=list.ToArray();
      

  7.   

    List<PointF> lpf = new List<PointF>();
    lpf.Add(........);
    g.DrawClosedCurve(pen, lpf.Select(x => new PointF(x.X, x.Y)).ToArray());
      

  8.   

    使用动态数组,也就是ArrayList
    然后获取数组长度就可以了
      

  9.   

    ArrayList List = new ArrayList();
    for( int i=0;i<10;i++ ) //给数组增加10个Int元素
             List.Add(i); 
    Int32[] values = (Int32[])List.ToArray(typeof(Int32));//返回ArrayList包含的数组