Link Details

Link 803913 thumbnail
User 866503 avatar

By BlackRabbitCoder
via blackrabbitcoder.net
Published: Jun 09 2012 / 10:22

We’ve seen how the Select() extension method lets you project a sequence from one type to a new type which is handy for getting just parts of items, or building new items. But what happens when the items in the sequence are already the type you want, but the sequence itself is typed to an interface or super-type instead of the sub-type you need? For example, you may have a sequence of Rectangle stored in an IEnumerable> and want to consider it an IEnumerable> sequence instead. Today we’ll look at two handy extension methods, Cast>() and OfType>() which help you with this task.
  • 5
  • 0
  • 687
  • 478

Comments

Add your comment
User 866503 avatar

BlackRabbitCoder replied ago:

0 votes Vote down Vote up Reply

new post

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (5)



Voters Against This Link (0)



    Java EE7
    Written by: Andrew Lee Rubinger
    Featured Refcardz: Top Refcardz:
    1. Design Patterns
    2. OO JS
    3. Cont. Delivery
    4. CI Patterns
    5. CI Tools
    1. Spring Integration
    2. Git
    3. Regex
    4. Java
    5. REST