new Dictionary<string, string> { {"a","n" }, {"b","n" }, {"c","n" }, {"d","n" }, {"e","n" }, {"f","n" }, };
public class TestA<Tkey,TValue> :IEnumerable<Tkey> { public void Add(Tkey key,TValue value) { } public IEnumerator<Tkey> GetEnumerator() { throw new NotImplementedException(); } IEnumerator IEnumerable.GetEnumerator() { throw new NotImplementedException(); } }
用ILSpy看下Dictionary就可以了。
用集合不可以吗
是说自定义的类怎么让他能这样初始化
这个初始化方式叫做属性构造器。