ElementAtOrDefault
In this chapter you will learn:
Get to know ElementAtOrDefault operator
ElementAtOrDefault tries to get the value at specific position, if not found it will return a default value for the given data type.
using System;/*from j a v a2 s. c om*/
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
public class MainClass{
public static void Main(){
int[] numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9};
var query = numbers.ElementAtOrDefault(9);
Console.Write(query);
}
}
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » Linq Operators