Elements LastOrDefault

CSharp · Console

/Program.cs

using System;
using System.Linq;
					
public class Program
{
	public static void Main()
	{
		var numbers = new[] { 2, 4, 6, 8, 10 };

		int firstOrDefault = numbers.LastOrDefault(n => n < 0);
		
		Console.WriteLine(firstOrDefault);
	}
}
;