I think you mean something like that:
public class {
private int currentIndex = 0;
void method() {
...
string str = getNext();
...
}
string getNext() {
if(currentIndex < listBox2.Items.Count) {
return listBox2[currentIndex++];
else {
currentIndex = 0;
return "";
}
}
}
So the answer is to declare a variable with a broader scope than a method
scope, an instance variabe for example and use it as index. In C there was a
static keyword you could use inside a function but it is not possible in C#.
"trint" wrote:
for (int i = 0; i < listBox2.Items.Count; i+=1)<<something like this?
{
thisString[i] = (string)listBox10.Items[i];
}
Any help is appreciated.
Thanks,
Trint