Listnumbers = new List { 3, 7, 4, 5, 2, 9 }; int firstEven = numbers.FirstOrDefault(n => n % 2 == 0); // Output: firstEven = 4
class Student { public string Name { get; set; } public double GPA { get; set; } } ListThe package library for the Microsoft.VisualStudio.TestTools.UnitTesting library in C# is Microsoft.VisualStudio.QualityTools.UnitTestFramework.students = new List { new Student { Name = "John", GPA = 3.2 }, new Student { Name = "Jane", GPA = 3.8 }, new Student { Name = "Bob", GPA = 3.1 }, new Student { Name = "Mary", GPA = 3.9 } }; Student honorStudent = students.FirstOrDefault(s => s.GPA > 3.5); // Output: honorStudent = { Name = "Jane", GPA = 3.8 }