本文整理汇总了C#中System.Collections.Generic.Except方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.Except方法的具体用法?C# System.Collections.Generic.Except怎么用?C# System.Collections.Generic.Except使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic
的用法示例。
在下文中一共展示了System.Collections.Generic.Except方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: should_get_sequence_excpetions
public void should_get_sequence_excpetions()
{
var firstSequence = new[] { 1, 2, 3 };
var secondSequence = new[] { 4, 3, 5 };
IEnumerable<int> except = firstSequence.Except(secondSequence);
// please update variable value to fix the test.
IEnumerable<int> expectedIntersection = new[] { 1, 2, 3 };
Assert.Equal(expectedIntersection, except);
}
示例2: HashSetWithBuiltInComparer_HashSetContainsNotUsed
public void HashSetWithBuiltInComparer_HashSetContainsNotUsed()
{
IEnumerable<string> input1 = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "a" };
IEnumerable<string> input2 = new[] { "A" };
Assert.Equal(new[] { "a" }, input1.Except(input2));
Assert.Equal(new[] { "a" }, input1.Except(input2, null));
Assert.Equal(new[] { "a" }, input1.Except(input2, EqualityComparer<string>.Default));
Assert.Equal(Enumerable.Empty<string>(), input1.Except(input2, StringComparer.OrdinalIgnoreCase));
Assert.Equal(new[] { "A" }, input2.Except(input1));
Assert.Equal(new[] { "A" }, input2.Except(input1, null));
Assert.Equal(new[] { "A" }, input2.Except(input1, EqualityComparer<string>.Default));
Assert.Equal(Enumerable.Empty<string>(), input2.Except(input1, StringComparer.OrdinalIgnoreCase));
}