Change the foreach loop into the LINQ query

 string one = "1"; //an exaplme 
  string two = "2"; //an exaplme 
 
  foreach (var item in myStringsList) 
  { 
      string[] splitted = item.Split(new char[] { '_' }, 
                                     StringSplitOptions.RemoveEmptyEntries); 
 
      if(splitted.Length >= 3) 
      { 
          if(splitted[1] == one && splitted[2] == two) 
          { 
              resultList.Add(item); 
          } 
      } 
  } 

  

posted @ 2012-05-23 01:45  轻量级程序员  阅读(216)  评论(0编辑  收藏  举报
关注获取博文附件