Okay, lets assume we have a variable with an array like this
int[] digit;
int x = 5;
for(int i=0;i < = 5; i++)
{ digit[i] = 0;}
All value array on var Digit have 0. So what i want to do its i want to increment the value on that digit from right using Button Control that adds increment (that means digit[4] to digit[3] and so on) and when the value hits certain number example 5 in digit[4], it would come back to value 0 and the next var digit incremented (digit[3]). And the incremented start again and so on.
I already try using if and switch to make this happen like this
private btnClick_Click(Object Sender, Event Args)
{
digit[4] +=1;
if(digit[4] > 5) { digit[3] += 1;}
if(digit[3] > 5) { digit[2] += 1;}
//and so on
switch(digit[4])
{
case 5: digit[4]=0;
}
//and so on
}
But its only for logic If We Know The Array Number Location. Say if i retrieve that number for somewhere like 15 digit. If we set array number so little on that command Button, it cannot fill the array right?
Imma already confused thinking this, any suggestion, help, discussion ill appreciate it. Thanks.
i <= 5will make theforloop fail with anIndexOutOfRangeException. It would be helpful to include executable code and a clear description of your problem.new int[5]creates an array with every element set to 0 to start with, so your initial loop is pointless.