Well there certainly is a datastructure that can do just this. A queue
Queue<stringfoo = new Queue<string>();
foo.Enqueue("Hello");
foo.Enqueue("Hello2");
foo.Enqueue("Hello3");
then whenever you need a string you simply use
string s = foo.Dequeue();
foo.Enqueue(s);
This will provide your wrap around functionality for you.
Cheers,
Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"Markus Stoeger" <sp******@gmx.atwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
metaperl wrote:
>Hi, I wrote a Forms program which toggles a label each time you click
it:
private void button1_Click(object sender, EventArgs e)
{
label1.Text = (label1.Text == "hello") ? "goodbye" :
"hello" ;
}
but in the interest of scaleability, I want this program to store the
.. very enterprisey ;)
>label values in a collection, access them via Next() and cycle back to
the beginning when the end of the collection is reached.
Any pointers to something in the .NET library which allows this?
I don't think there is such a collection in the .NET library. You'll
probably have to create your own custom collection.
Besides only adding the label values you could also add delegates to the
collection. This way you could create a method Execute() which executes
the Method associated with the current label.
Max