我有一个自定义的结构体        public struct LimitPoint
        {
            public Rectangle rcAngle;
            public PointF point;
            public bool bDown;
        }        List<LimitPoint> dinosaurs = new List<LimitPoint>();
也添加了几个元素
            dinosaurs.Add(lpMin);
            dinosaurs.Add(lpMax);
然后重新赋值时:
                    dinosaurs[i].bDown = true;    i存在的,没有越界报错误:
错误 CS1612: 无法修改“System.Collections.Generic.List<testList.Form1.LimitPoint>.this[int]”的返回值,因为它不是变量求高手该怎么修改,解决马上结贴!

解决方案 »

  1.   

    LimitPoint lp = dinosaurs[i];
    lp.bDown = true;
    dinosaurs[i] = lp;
      

  2.   

    public bool bDown{get;set;}
    for(int i=0li<dinosaurs.Cont;i++)
    {
    dinosaurs[i].bDown = true;
    }
      

  3.   


    只能 通过 间接的去赋值了:
    var v = dinosaurs[i];
    v.bDown = true
      

  4.   

    http://generally.wordpress.com/2007/06/21/c-list-of-struct/
      

  5.   

    只能写:
    LimitPoint temp = dinosaurs[i];
    temp.bDown = true;
    dinosaurs[i] = temp;
    原因详见我博客中的解释:
    List中的值类型无法修改的原因详解