string字符串根据指定字符进行截取转成对应的集合

获取List<string>

List<string> ipList = 字符串.Split(new char[] { '截取字符' }, StringSplitOptions.RemoveEmptyEntries).ToList();

获取List<int>

var sNumbers = "1,2,3,4,5,6";
List<int> numbers = sNumbers.Split(new char[]{','},StringSplitOptions.RemoveEmptyEntries).Select(Int32.Parse).ToList();

 


posted @ 2021-11-02 11:17  博客YS  阅读(751)  评论(0编辑  收藏  举报