Hi everyone,
First off this is my first post on this site so hello again.
I'm a beginner at programming in C#/ASP so the code I'm about show you may be bad practice or even worse but I'm getting better I hope.
What I want: I want to populate a hashtable(compl eteList) with an arraylist(myArr List) to do this I'm using a for loop which also appends information from another arraylist(nameL istArray) to a string(nameList )
What I have:
The problem:
If my nameListArray contains less then 5 entries the if @line20 won't be executed but when it's larger then 5 no 'error' occurs. I've also found out when I'm commenting line 16 whether the array has less then 5 or more entries the program will execute it.
Can anyone help me please?
First off this is my first post on this site so hello again.
I'm a beginner at programming in C#/ASP so the code I'm about show you may be bad practice or even worse but I'm getting better I hope.
What I want: I want to populate a hashtable(compl eteList) with an arraylist(myArr List) to do this I'm using a for loop which also appends information from another arraylist(nameL istArray) to a string(nameList )
What I have:
Code:
Hashtable completeList = new Hashtable();
ArrayList myArrList = new ArrayList();
string[] nameListArray = new string[20];
string nameList = "";
//**********************************//
if(myArrlist.Count > 1)
{
//some code
int j = arraystate;
for(int i = 1; i < 5; i++)
{
nameList += i+". "+nameListArray[j];
completeList.Add("0"+i, myArrList[j].ToString());
j++;
}
if(arraystate != 15)
{completeList.Add("0", nameList+"N. for Next");}
else
{completeList.Add("0", nameList);}
}
else
{
//some code
}
If my nameListArray contains less then 5 entries the if @line20 won't be executed but when it's larger then 5 no 'error' occurs. I've also found out when I'm commenting line 16 whether the array has less then 5 or more entries the program will execute it.
Can anyone help me please?
Comment