本文整理汇总了C#中System.Collections.Generic.Last方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.Last方法的具体用法?C# System.Collections.Generic.Last怎么用?C# System.Collections.Generic.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic
的用法示例。
在下文中一共展示了System.Collections.Generic.Last方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: when_using_a_visitor
public void when_using_a_visitor()
{
//setup
var controller = new PropertyBagVersionController<FlatPropertyBag>(TestHelper.CreateWithNonDefaultProperties<FlatPropertyBag>(),
_testHelper.MakeConfiguredCloneFactoryFor<FlatPropertyBag>(),
_testHelper.EmptyChangeSet(),
_testHelper.MakeConfiguredVisitorFactory(),
_testHelper.MakeConfiguredProxyFactory());
var fakeChildren = new[] {A.Fake<IVersionControlNode>(), A.Fake<IVersionControlNode>()};
var fakeVisitor = A.Fake<IVersionControlTreeVisitor>();
controller.Children.AddRange(fakeChildren);
//act
controller.Accept(fakeVisitor);
//assert
A.CallTo(() => fakeChildren.First().RecursiveAccept(fakeVisitor)).MustHaveHappened();
A.CallTo(() => fakeChildren.Last().RecursiveAccept(fakeVisitor)).MustHaveHappened();
A.CallTo(() => fakeVisitor.OnEntry(controller)).MustHaveHappened();
}
示例2: should_get_last_element_using_last
public void should_get_last_element_using_last()
{
var sequence = new[] { 1, 2, 3, 4, 5 };
int lastElement = sequence.Last();
int lastEvenNumber = sequence.Last(item => item % 2 == 0);
// please update variable values for the following 2 lines to fix the test.
const int expectedLastElement = 0;
const int expectedLastEvenNumber = 0;
Assert.Equal(expectedLastElement, lastElement);
Assert.Equal(expectedLastEvenNumber, lastEvenNumber);
}