description | title | ms.date | ms.assetid |
---|---|---|---|
Learn more about: Element Operations (Visual Basic) |
Element Operations |
07/20/2015 |
5fcb0631-dce5-45ff-8abb-353cae21e14f |
Element operations return a single, specific element from a sequence.
The standard query operator methods that perform element operations are listed in the following section.
Method Name | Description | Visual Basic Query Expression Syntax | More Information |
---|---|---|---|
ElementAt | Returns the element at a specified index in a collection. | Not applicable. | xref:System.Linq.Enumerable.ElementAt%2A?displayProperty=nameWithType xref:System.Linq.Queryable.ElementAt%2A?displayProperty=nameWithType |
ElementAtOrDefault | Returns the element at a specified index in a collection or a default value if the index is out of range. | Not applicable. | xref:System.Linq.Enumerable.ElementAtOrDefault%2A?displayProperty=nameWithType xref:System.Linq.Queryable.ElementAtOrDefault%2A?displayProperty=nameWithType |
First | Returns the first element of a collection, or the first element that satisfies a condition. | Not applicable. | xref:System.Linq.Enumerable.First%2A?displayProperty=nameWithType xref:System.Linq.Queryable.First%2A?displayProperty=nameWithType |
FirstOrDefault | Returns the first element of a collection, or the first element that satisfies a condition. Returns a default value if no such element exists. | Not applicable. | xref:System.Linq.Enumerable.FirstOrDefault%2A?displayProperty=nameWithType xref:System.Linq.Queryable.FirstOrDefault%2A?displayProperty=nameWithType xref:System.Linq.Queryable.FirstOrDefault%60%601%28System.Linq.IQueryable%7B%60%600%7D%29?displayProperty=nameWithType |
Last | Returns the last element of a collection, or the last element that satisfies a condition. | Not applicable. | xref:System.Linq.Enumerable.Last%2A?displayProperty=nameWithType xref:System.Linq.Queryable.Last%2A?displayProperty=nameWithType |
LastOrDefault | Returns the last element of a collection, or the last element that satisfies a condition. Returns a default value if no such element exists. | Not applicable. | xref:System.Linq.Enumerable.LastOrDefault%2A?displayProperty=nameWithType xref:System.Linq.Queryable.LastOrDefault%2A?displayProperty=nameWithType |
Single | Returns the only element of a collection, or the only element that satisfies a condition. | Not applicable. | xref:System.Linq.Enumerable.Single%2A?displayProperty=nameWithType xref:System.Linq.Queryable.Single%2A?displayProperty=nameWithType |
SingleOrDefault | Returns the only element of a collection, or the only element that satisfies a condition. Returns a default value if no such element exists or the collection does not contain exactly one element. | Not applicable. | xref:System.Linq.Enumerable.SingleOrDefault%2A?displayProperty=nameWithType xref:System.Linq.Queryable.SingleOrDefault%2A?displayProperty=nameWithType |