Specify the default value for an empty sequence in DefaultIfEmpty operator
using System; using System.Linq; using System.Collections; using System.Collections.Generic; class Program/* w ww . j a va 2s . c o m*/ { static void Main(string[] args) { string[] codeNames = {"Python", "Java", "A", "Bash", "C++", "Oracle"}; string name = codeNames.Where(n => n.Equals("Jones")).DefaultIfEmpty("Missing").First(); Console.WriteLine(name); } }