LINQ - is SkipWhile broken?

前端 未结 5 635
醉话见心
醉话见心 2020-12-30 22:54

I\'m a bit surprised to find the results of the following code, where I simply want to remove all 3s from a sequence of ints:

var sequence = new [] { 1, 1, 2         


        
5条回答
  •  醉酒成梦
    2020-12-30 23:19

    Ahmad already answered your question, but here's another option:

    var result = from i in sequence where i != 3 select i;
    

提交回复
热议问题