当前位置: 首页>>代码示例>>C#>>正文


C# LinkedList.LastOrDefault方法代码示例

本文整理汇总了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());
 }
开发者ID:jamesmanning,项目名称:IEnumerableWithCount,代码行数:5,代码来源:LastOrDefaultTest.cs

示例2: NullPredicate

 public void NullPredicate()
 {
     var source = new LinkedList<int>(new int[] { 1, 3, 5 });
     Assert.Throws<ArgumentNullException>(() => source.LastOrDefault(null));
 }
开发者ID:olexandr17,项目名称:kottans,代码行数:5,代码来源:LastOrDefaultTest.cs

示例3: EmptySequenceWithoutPredicate

 public void EmptySequenceWithoutPredicate()
 {
     var source = new LinkedList<int>();
     Assert.AreEqual(0, source.LastOrDefault());
 }
开发者ID:jamesmanning,项目名称:IEnumerableWithCount,代码行数:5,代码来源:LastOrDefaultTest.cs

示例4: SingleElementSequenceWithNonMatchingPredicate

 public void SingleElementSequenceWithNonMatchingPredicate()
 {
     var source = new LinkedList<int>(new int[] { 2 });
     Assert.AreEqual(0, source.LastOrDefault(x => x > 3));
 }
开发者ID:olexandr17,项目名称:kottans,代码行数:5,代码来源:LastOrDefaultTest.cs

示例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));
 }
开发者ID:olexandr17,项目名称:kottans,代码行数:5,代码来源:LastOrDefaultTest.cs

示例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());
 }
开发者ID:dnperfors,项目名称:DotNetScratchPad,代码行数:5,代码来源:LastOrDefaultTests.cs

示例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));
 }
开发者ID:dnperfors,项目名称:DotNetScratchPad,代码行数:5,代码来源:LastOrDefaultTests.cs

示例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());
 }
开发者ID:dnperfors,项目名称:DotNetScratchPad,代码行数:5,代码来源:LastOrDefaultTests.cs

示例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));
 }
开发者ID:dnperfors,项目名称:DotNetScratchPad,代码行数:6,代码来源:LastOrDefaultTests.cs

示例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));
 }
开发者ID:dnperfors,项目名称:DotNetScratchPad,代码行数:5,代码来源:LastOrDefaultTests.cs


注:本文中的LinkedList.LastOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。