版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_27559331/article/details/80612972

1 int[] selects= Array.ConvertAll<string, int>(IDList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.StringToInt32()); //string分割转int[] 
2 List<int> selects = Array.ConvertAll<string, int>(IDList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.StringToInt32() ).Distinct().ToList(); //string分割转list<int>

 


 

StringToInt32()是string的扩展方法

 1 /// <summary>
 2 /// 扩展类
 3 /// </summary>
 4 public static class Extension
 5 {
 6 public static int StringToInt32(this string str)
 7 {
 8 int num = -1;
 9 if (int.TryParse(str, out num))
10 {
11 return num;
12 }
13 else
14 {
15 return -1;
16 } 
17 }
18 }

 


 

原文链接:https://blog.csdn.net/qq_27559331/article/details/80612972

 

 勿谈他人拿高薪;且看闲时谁在拼;

相关文章:

  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
  • 2021-10-18
  • 2021-06-14
  • 2022-12-23
  • 2021-08-28
  • 2021-10-20
猜你喜欢
  • 2022-12-23
  • 2021-11-27
  • 2021-08-25
  • 2022-12-23
  • 2021-10-16
  • 2021-08-07
  • 2022-12-23
相关资源
相似解决方案