c# - How Can I send next element of array on each click of button? -
I have the string [] arr I want to do this so that if I click on the button, [0] lesson Box and if I click on the button then [1] goes to the text box.
I know that some counter will be used and it is being extended on every click but im just confused with syntax, assistance will be appreciated.
Here's a sample:
int _Counter = 0; String [] arr = new string [4] {"1", "2", "3", "4"}; Private Zero Button (Object Sender, EventArgs e) {textbox.Text = arr [_Counter]; _Counter ++; If (_Counter == arr.Length) {_Counter = 0;}} If you are using it in the ASP.NET application, you should store _Counter in ViewState, Session or Cookie needed. / P>
Comments
Post a Comment