
Element Operator-FirstOrDefault
The FirstOrDefault operator returns the first element of a sequence, or a default value if no element is found.
This sample uses FirstOrDefault to try to return the first element of the sequence, unless there are no elements, in which case the default value for that type is returned.
Example:
| using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication4 int firstNumOrDefault = numbers.FirstOrDefault(); Console.WriteLine(firstNumOrDefault); Console.ReadLine(); |
Output:
Aspnet Discussion
- - Web application
- - Great Indian Developer Su
- - Aspx page inside Silverli
- - Open aspx page inside Sil
- - Guidance for a novice




