Use FirstOrDefault operator with condition and an Element Is Not Found
using System; using System.Linq; using System.Collections; using System.Collections.Generic; class Program/* w ww .ja v a2 s. c o m*/ { static void Main(string[] args) { string[] codeNames = {"Python", "Java", "Javascript", "Bash", "C++", "Oracle"}; string name = codeNames.FirstOrDefault(p => p.StartsWith("Z")); Console.WriteLine(name == null ? "NULL" : name); } }