DNK has a spanking new server up and running like clockwork. Stability problems are a thing of the past. Our new monitoring service reports 100% uptime since the move!
41
kicks
published 1 year, 7 months ago, submitted by manovich 1 year, 7 months ago

dotnettipoftheday.org — Small example of how to use Action delegate to perform some action on all elements of a collection.

Add a comment 9 comments | category: | Views: 130 | Get KickIt image code
Create elegant code with Action delegate and List.ForEach method
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:
wow crazy tip. good post!
posted by bladefist 1 year, 7 months ago
Cool stuff! I like it!
posted by JudahGabriel JudahGabriel 1 year, 7 months ago
You don't even need a delegate to do this sort of thing. Just use a method that has the same signature. For example, I use Regex' IsMatch method all the time with the Filter<T> method of Array.

Regex foo = new Regex(".*Lol.*");

string[] linesThatContainLol = Array.Filter<string>(sourceArray, foo.IsMatch);
posted by yesthatmcgurk yesthatmcgurk 1 year, 7 months ago
1) The tip doesn't specifically cast to the Action delegate, which is what I was implying above
2) I hate emoticons. They must die. Die emoticons die.
posted by yesthatmcgurk yesthatmcgurk 1 year, 7 months ago
@yesthatmcgurk: Nice one. I am kinda amazed this level of tips gets that many kicks but fair enough, the comments make up for it. Here's another one...

string[] a = { "1", "2" };
int[] b = Array.ConvertAll<string,int>(a, int.Parse);
posted by fquednau fquednau 1 year, 7 months ago
To have automatic emoticon functionality where code may be potentially posted is indeed very wrong.
posted by fquednau fquednau 1 year, 7 months ago
We're working on this.
posted by simoneb simoneb 1 year, 7 months ago
the following code cures cancer
:D=):););(:(:,(;):D
posted by bladefist 1 year, 7 months ago
@bladefist: LOL
posted by jesse 1 year, 7 months ago



information Login or create an account to comment on this story

Related Stories:
 

Search: