Re: foreach in two dimensional array in C#
From: Bob Grommes (bob_at_bobgrommes.com)
Date: 10/07/04
- Next message: Robert Jordan: "Re: Serialization and Deserialization"
- Previous message: Amadelle: "Re: Serialization and Deserialization"
- In reply to: Gopal Krish: "foreach in two dimensional array in C#"
- Next in thread: Gopal Krish: "Re: foreach in two dimensional array in C#"
- Reply: Gopal Krish: "Re: foreach in two dimensional array in C#"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 7 Oct 2004 15:37:35 -0700
I think you really need a for loop for this kind of thing. At present, it's
slightly faster than a foreach anyway (not that this probably matters in
this context).
--Bob
"Gopal Krish" <geeksgk@yahoo.com> wrote in message
news:8b4092e6.0410061938.489699f6@posting.google.com...
> Any sample code that uses foreach statement to walkthrough a two
> dimensional array? My requirement is to process data in only one
> dimension (say column 0 in each row of the array)
>
> Example
> menulinks[0,0] = "My Home";
> menulinks[0,1] = "MyHome.aspx";
>
> menulinks[1,0] = "Credit";
> menulinks[1,1] = "Credit.aspx";
>
> menulinks[2,0] = "Debit";
> menulinks[2,1] = "debit.aspx";
>
>
> foreach (string menuitem in menulinks)
> {
> Label1.Text += " " + menuitem
> }
>
> Current Output in Label1.Text
> " My Home MyHome.aspx Cerdit Credit.aspx Debit debit.aspx"
>
> What I needed
> " My Home Cerdit Debit"
- Next message: Robert Jordan: "Re: Serialization and Deserialization"
- Previous message: Amadelle: "Re: Serialization and Deserialization"
- In reply to: Gopal Krish: "foreach in two dimensional array in C#"
- Next in thread: Gopal Krish: "Re: foreach in two dimensional array in C#"
- Reply: Gopal Krish: "Re: foreach in two dimensional array in C#"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|