Get LastOrDefault returned from Take in CSharp
Description
The following code shows how to get LastOrDefault returned from Take.
Example
using System;//from ww w. j a v a2s. com
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass {
public static void Main() {
string[] presidents = {"HTML", "HTML5", "CSS", "CSS3", "Java", "XML"};
string name = presidents.Take(0).LastOrDefault();
Console.WriteLine(name == null ? "NULL" : name);
}
}
The code above generates the following result.