How can I implement NotOfType in LINQ that has a nice calling syntax?

前端 未结 7 1179
轻奢々
轻奢々 2020-12-11 00:24

I\'m trying to come up with an implementation for NotOfType, which has a readable call syntax. NotOfType should be the complement to OfType&l

7条回答
  •  攒了一身酷
    2020-12-11 00:56

    I've just tried this and it works...

    public static IEnumerable NotOfType(this IEnumerable sequence)
        => sequence.Where(x => !(x is TExclude));
    

    Am I missing something?

提交回复
热议问题