FirstOrDefault method (with integers)

Description

The FirstOrDefault method returns the first element of a sequence, or a default value if no element is found.

Sample

This sample returns 0, because the list is empty.

var data := List<int>{}

var result := data:FirstOrDefault()

Console.WriteLine(result)

Output

0

Complete sample

using System
using System.Linq
using System.Collections.Generic

procedure Execute() as void strict

   var data := List<int>{}

   var result := data:FirstOrDefault()

   Console.WriteLine(result)
   return