當前位置:成語大全網 - 新華字典 - c# 字符串 字典

c# 字符串 字典

string [] values = mstr.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

Dictionary<int,string> datas = new Dictionary<int,string>();

foreach(string str in values )

{

string [] temp_value = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

if(temp_value !=null&&temp_value .Length == 2)

{

int key = Convert.ToInt32( temp_value [0]);

datas.Add(key,temp_value [1]);

}

}