// x is compiled as an int
var x = 10;
// y is compiled as a string
var y = "Hello";
// z is compiled as int[]
var z = new[] { 0, 1, 2 };
但
// ano is compiled as an anonymous type
var ano = new { x1 = 10, y1 = "Hello" };
ano
创建的对象的属性是只读的。我想弄清楚为什么这些属性是只读的。建议表示赞赏?
编辑:
var ano1 = new { x1 = 10, y1 = "Hello" };
var ano2 = new { x1 = 10, y1 = "Hello" };
如果新的匿名类型以相同的顺序具有相同数量和类型的属性,它是否与第一个具有相同的内部类型?