First method (with integers)

Description

The First method returns the first element of a sequence or throws an exception, if the sequence is empty.

Sample

This sample gets the first element.

var data := List<int>{} { 5, 3, 1, 2, 4 }

var result := data:First()

Console.WriteLine(result)

Output

5

Complete sample

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

procedure Execute() as void strict

   var data := List<int>{} { 5, 3, 1, 2, 4 }

   var result := data:First()

   Console.WriteLine(result)
   return