List<string> ls = new List<string>() { "1", "2", "3" };
List<int> li = ls.ConvertAll<int>(i => int.Parse(i));
string fields = "First Name,Middle Name,Last Name,Birth Date,Gender,Address,City,State,Zip,Email";
List<string> fieldList = new List<string>(fields.Split(','));
List<string> lst = fieldList.ConvertAll<string>(x => x.ToLower().Contains("city") ? x = "true" : "false");
Hashtable ht = new Hashtable(); //创建一个Hashtable实例
ht.Add("上海", "东方明珠");
ht.Add("广州", "广州塔");
ht.Add("深圳", "欢乐海岸");
string capital = (string)ht["北京"];
var f = ht.Contains("上海"); //判断哈希表是否包含特定键,其返回值为true或false
//ht.Remove("深圳"); //移除一个keyvalue键值对
//ht.Clear(); //移除所有元素
ConvertAll与Hashtable用法
最新推荐文章于 2024-05-13 16:16:13 发布