03.01.2015 Views

C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

LINQ Functions ❘ 767<br />

LINQ Functions<br />

The following table summarizes LINQ useful extension methods that are not available from<br />

<strong>C#</strong> LINQ query syntax.<br />

Function<br />

Aggregate<br />

Concat<br />

Contains<br />

DefaultIfEmpty<br />

ElementAt<br />

ElementAtOrDefault<br />

Empty<br />

Except<br />

Intersection<br />

Range<br />

Repeat<br />

SequenceEqual<br />

Union<br />

Purpose<br />

Uses a function specified by the code to calculate a custom<br />

aggregate<br />

Concatenates two sequences into a new sequence<br />

Returns true if the result contains a specific value<br />

Returns the query’s result or a default value if the query returns<br />

an empty result<br />

Returns an element at a specific position in the query’s result<br />

Returns an element at a specific position in the query’s result or a<br />

default value if there is no such position<br />

Creates an empty IEnumerable<br />

Returns the items in one IEnumerable that are not in a second<br />

IEnumerable<br />

Returns the intersection of two IEnumerable objects<br />

Creates an IEnumerable containing a range of integer values<br />

Creates an IEnumerable containing a value repeated a specific<br />

number of times<br />

Returns true if two sequences are identical<br />

Returns the union of two IEnumerable objects<br />

The following table summarizes LINQ data type conversion methods.<br />

Function<br />

AsEnumerable<br />

AsQueryable<br />

OfType<br />

ToArray<br />

Purpose<br />

Converts the result to IEnumerable<br />

Converts an IEnumerable to IQueryable<br />

Removes items that cannot be cast into a specific type<br />

Places the results in an array<br />

continues<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!