是否可以同时组合 List 初始化程序和对象初始化程序?给定以下类定义:
class MyList : List<int>
{
public string Text { get; set; }
}
// we can do this
var obj1 = new MyList() { Text="Hello" };
// we can also do that
var obj2 = new MyList() { 1, 2, 3 };
// but this one doesn't compile
//var obj3 = new MyList() { Text="Hello", 1, 2, 3 };
这是设计使然,还是只是 c# 编译器的错误或缺失功能?