dictionary如何在初始化时赋值?
如:
List<string> list = new List(){
"asd",
"123"
};
求指教!!
------解决方案--------------------------------------------------------
Dictionary<int, string> dict = new Dictionary<int, string>() { { 1, "1" }, { 2, "2" } };
------解决方案--------------------------------------------------------
Dictionary<int, string> dic = new Dictionary<int, string>
{
{1,"a"}, {2,"b"}
};
------解决方案--------------------------------------------------------
楼上2位回答的都对啊
------解决方案--------------------------------------------------------
是啊!!楼上的方法就是对的,为什么不自己试一下呢!