Monday, February 25, 2008
« TextBox MaxLength from LINQ Meta Data | Main | LINQ WhereIf Extension Method »

An update on an older posting now that we have LINQ:

 

string[] input = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };

 

// old

int[] output = Array.ConvertAll<string, int>(input, delegate(string s) { return int.Parse(s); });

 

// new

int[] output = Array.ConvertAll(input, s => int.Parse(s));

 

// even better

input.Select(s => int.Parse(s)).ToArray();

 

// better yet

input.Select(s => int.Parse(s)).ToList();

 

kick it on DotNetKicks.com   Monday, February 25, 2008 4:19:12 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [2]  | 
Sunday, December 11, 2011 5:45:01 PM (Pacific Standard Time, UTC-08:00)
Surprisingly well-written and informative for a free online arictle.
Thursday, December 15, 2011 3:11:38 AM (Pacific Standard Time, UTC-08:00)
dB1k3T , [url=http://ywuikfegchzr.com/]ywuikfegchzr[/url], [link=http://hekrpnkmgulg.com/]hekrpnkmgulg[/link], http://zoapplvpbioh.com/
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview