本文整理汇总了C#中LinkedList.LastOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# LinkedList.LastOrDefault方法的具体用法?C# LinkedList.LastOrDefault怎么用?C# LinkedList.LastOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList
的用法示例。
在下文中一共展示了LinkedList.LastOrDefault方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SingleElementSequenceWithoutPredicate
public void SingleElementSequenceWithoutPredicate()
{
var source = new LinkedList<int>(new int[] { 5 });
Assert.AreEqual(5, source.LastOrDefault());
}
示例2: NullPredicate
public void NullPredicate()
{
var source = new LinkedList<int>(new int[] { 1, 3, 5 });
Assert.Throws<ArgumentNullException>(() => source.LastOrDefault(null));
}
示例3: EmptySequenceWithoutPredicate
public void EmptySequenceWithoutPredicate()
{
var source = new LinkedList<int>();
Assert.AreEqual(0, source.LastOrDefault());
}
示例4: SingleElementSequenceWithNonMatchingPredicate
public void SingleElementSequenceWithNonMatchingPredicate()
{
var source = new LinkedList<int>(new int[] { 2 });
Assert.AreEqual(0, source.LastOrDefault(x => x > 3));
}
示例5: MultipleElementSequenceWithSinglePredicateMatch
public void MultipleElementSequenceWithSinglePredicateMatch()
{
var source = new LinkedList<int>(new int[] { 1, 2, 5, 2, 1 });
Assert.AreEqual(5, source.LastOrDefault(x => x > 3));
}
示例6: Should_return_only_value_when_source_has_one_value
public void Should_return_only_value_when_source_has_one_value()
{
var source = new LinkedList<int>(new int[] { 5 });
Assert.Equal(5, source.LastOrDefault());
}
示例7: Should_return_only_element_matchin_predicate
public void Should_return_only_element_matchin_predicate()
{
var source = new LinkedList<int>(new int[] { 5 });
Assert.Equal(5, source.LastOrDefault(x => x > 3));
}
示例8: Should_return_last_value_when_source_has_more_than_one_value
public void Should_return_last_value_when_source_has_more_than_one_value()
{
var source = new LinkedList<int>(new int[] { 5, 10, 14 });
Assert.Equal(14, source.LastOrDefault());
}
示例9: Should_return_default_value_when_source_is_empty
public void Should_return_default_value_when_source_is_empty()
{
var source = new LinkedList<int>();
Assert.Equal(default(int), source.LastOrDefault());
Assert.Equal(default(int), source.LastOrDefault(x => x > 3));
}
示例10: Should_return_default_value_when_only_element_doesnot_match_perdicate
public void Should_return_default_value_when_only_element_doesnot_match_perdicate()
{
var source = new LinkedList<int>(new int[] { 3 });
Assert.Equal(default(int), source.LastOrDefault(x => x > 3));
}