DotNetKick.com is an open-source project. Please report any bugs and let us know your great suggestions. Currently running svn revision 637 (rss)

Kick Spy!, Kick Zeitgeist and Kick Widgets

17
kicks
published 1 year, 6 months ago, submitted by dwhittaker 1 year, 6 months ago

devlicio.us — If you've ever tried to cast been list generics, you know that you can't.

tags: , , , | tag it

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:
I find using a generic method for this a lot easier:

public IEnumerable<TBase> As<TBase, TDerived>(IEnumerable<TDerived> derived)
where TDerived : TBase
{
foreach(TDerived item in derived) yield return item;
}

You call it like this:

// C# 2
IEnumerable<Square> mySquares = ...;
IEnumerable<Shape> myShapes = As<Shape, Square>(mySquares);

// C# 3 with extension methods would make it a little more natural:
IEnumerable<Shape> myShapes = mySquares.As<Shape>();
posted by JudahGabriel JudahGabriel 1 year, 6 months ago
Oh, and if you need to create a list from that, it's as simple as saying

List<Shape> shapes = new List<Shape>(myShapes);
posted by JudahGabriel JudahGabriel 1 year, 6 months ago



information Login or create an account to comment on this story
 

Sponsored Link: www.carlist.ie

Search:

Ads by The Lounge