LINQ Conversion Operators (ToList, ToArray, ToLookup, Cast, OfType)

  Total Views : 233
  Comments : 0
 
  Keywords : Conversion operators in linq with examples, Linq conversion operators in c# / vb.net with examples, Different types of linq conversion operators tolist / toarray / tolookup / asenumerable

Here we will learn linq conversion operators with examples in c#, vb.net and different types of linq conversion operators (toarray, tolist, tolookup, cast, oftype, asenumerable, asqueryable) with examples.

LINQ Conversion Operators

In LINQ conversion operators are used to convert the type of elements in list / collection. In LINQ we have different types of conversion operators available those are 

 

  1. TOLIST
  2. TOARRAY
  3. TOLOOKUP
  4. CAST
  5. OFTYPE
  6. ASENUMERABLE
  7. ASQUERYABLE

By using these conversion operators we can convert type of elements in list.

 

Following table shows more detailed information related to conversion operators.

 

OperatorDescription
ToList It converts a collection to List
ToArray It converts a collection to an array
ToLookUp It converts group of elements into Lookup<tkey, telement>
Cast It converts non-generic list to generic list (IEnumerable to IEnumerable)
OfType ItIt is used to filters collection based on specified type
AsEnumerable It is used to convert input elements as IEnumerable
AsQueryable It converts IEnumerable to IQueryable
ToDictionary It converts input elements into dictionary based on key selector function

In coming chapters we will learn each conversion operator with examples.

 Comments (0)

Be the first to give your valuable feedback

Leave a comment

  • Default Tutlane User