我自定义了一个结构体
struct Area
{
    int a;
    Point[] point;
}
赋值后 arraylist.Add(area) 调试显示这时数据正常.
取值时 Area area = new Area();
       area = (Area)list[0]; 这句话总出错,提示"指定的转换无效".
请问这是什么原因啊,是结构体里保存了Point[]数组的原因么?

解决方案 »

  1.   

    area   =   (Area)list[0];   
    应为area = (Area)arraylist(0); 你再试试看。
      

  2.   

    我觉得和结构体里有什么东东没关系,但不知道LZ为什么会出错。
    我试了这段代码,运行没有任何问题:
    using System;
    using System.Drawing;
    using System.Collections;class test
    {
        struct Area
        {
            public int a;
            public Point[] point;
        } ;    public static void Main()
        {
            ArrayList al = new ArrayList();
            Area area = new Area();
            area.a = 1;
            al.Add(area);
            Console.WriteLine(al[0].GetType().ToString());
            Area b = new Area();
            b = (Area)al[0];
            Console.WriteLine(b.a);
        }
    }