I am trying to form a list with the help of multi-dimensional array that should look like this.
[validatorKey][counter]
1453 10
1231 12
6431 7
1246 1
1458 2
however, I couldn’t cope with it. this is my method by the way. and also the array size should be incremented at the very end of the method. I know I should use Array.Resize(ref array, 2); but since my array is multi dimensional, in this case what should be the appropriate method.
private int AracaAitSeferSayisiDondur(int pValidatorKey)
{
int iSeferSayisi = 0;
int[,] iSeferListesi = (int[,])ViewState["SeferListesi"];
if (iSeferListesi == null)
iSeferListesi = new int[1,1];
bool aynisiVarmi = false;
for (int i = 0; i < iSeferListesi.Length; i++)
{
if (iSeferListesi[i,0] == pValidatorKey)
{
aynisiVarmi = true;
iSeferListesi[i,1]++;
iSeferSayisi = iSeferListesi[i,1]++;
break;
}
}
if (!aynisiVarmi)
{
int arrayLength = iSeferListesi.Length;
iSeferListesi[arrayLength--, 0] = pValidatorKey;
iSeferListesi[arrayLength--, 1] = 1;
//IN THIS PART ARRAY SIZE SHOULD BE INCREASED
iSeferSayisi = iSeferListesi[arrayLength--, 1];
}
ViewState["SeferListesi"] = iSeferListesi;
return iSeferSayisi;
}
I think you need sonmething like:
The double increment of iSeferListesi (derived from your code) is probably not what you want, without it the if/else logic becomes even simpler.