无法修改'表达式'的返回值因为它不是列表中的变量而是数组有效

时间:2017-01-22 21:19:59

标签: c# .net arrays value-type

为什么我在值类型为属性但不在数组上的结构列表中出现CS1612错误?

例如:

        List<VertexPositionColorTexture> y = new List<VertexPositionColorTexture>();
        y[0].Position = Vector3.Left; // CS1612
        VertexPositionColorTexture[] x = new VertexPositionColorTexture[4];
        x[0].Position = Vector3.Down; // fine

两者都试图修改一个值类型,为什么数组有效呢?

0 个答案:

没有答案