Input: | IEnumerable<TSource> |
Optional lambda expression: | TSource => bool |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
int[] numbers = { 1, 2, 3, 4, 5 };
int last = numbers.Last(); // 5
int lastEven = numbers.Last(n => n % 2 == 0); // 4
Console.WriteLine(last);
Console.WriteLine(lastEven);
}
}
The output:
5
4
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |