Home All Groups Group Topic Archive Search About
Author
19 Mar 2007 12:54 PM
Maury
Hi,
I made a vaery simple Join operation from an object[] (here I call it
myArray) to a string[]
using a Converter<Tinput, TOutput>

protected void Button1_Click(object sender, EventArgs e)
{
  Label1.Text = String.Join("|", Array.ConvertAll<object,
string>(myArray, new Converter<object,string>(CObj)));
}

protected static string CObj(object item)
{
return item.ToString();
}

How can I do the same operation using an anonymous method instead of
using
the static CObj  function?
Can you help me with the sintax?

Thanks!!!!

Author
19 Mar 2007 5:57 PM
Mattias Sjögren
>How can I do the same operation using an anonymous method instead of
>using
>the static CObj  function?
>Can you help me with the sintax?

Label1.Text = String.Join("|", Array.ConvertAll<object,
string>(myArray, delegate(object item) { return item.ToString(); } ));


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Author
20 Mar 2007 3:08 PM
Maury
On Mar 19, 6:57 pm, Mattias Sjögren <mattias.dont.want.s***@mvps.org>
wrote:
> Label1.Text = String.Join("|", Array.ConvertAll<object,
> string>(myArray, delegate(object item) { return item.ToString(); } ));

Thanks, I missed the keyword 'delegate'

AddThis Social Bookmark Button