Only iterating over the objects you want in a foreach loop(jeremyjarrell.com)

submitted by jeremyjarrelljeremyjarrell(2685) 5 years, 3 months ago

Have you ever had a collection made of several types which all derive from the same base class? How many times have you needed to iterate the whole collection and check each element to make sure its the type that you want to work with? Here's how to do you type checking completely inline inside of the foreach loop so you only get the objects you want.

1 comment |category: |Views: 8

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by jdh30jdh30(245) 5 years, 2 months ago 0

Learn F#. Use pattern matching.

Reply

information Login or create an account to comment on this story