使用List可以很方便的存放数据,这里介绍用到的两个方法:
1、使用数组填充
string[] arr=new string[]{"张三","李四","王五"}; List<string> list = new List<string>(arr);
2、使用Find,以FindAll为例:
List<string> inList = list.FindAll(delegate(string x) { return x == "张三"; });
还可以使用隐式委托:
list.FindAll(Search); public bool Search(string x) { return x =="张三"; }
发表评论
相关文章
想了解服务发现、配置管理的同学,欢迎加入1000人Consul交流群:234939415
扫码关注公众号:萤火架构
文章分类
最新评论