Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

doesn't have an indexer

Status
Not open for further replies.

slatet

Programmer
Sep 11, 2003
116
US
I am trying to pass in an arraylist and the index value for it. When I go to reference the array with the variable for the index, I get an error, doesn't have an indexer. But when I debug and use a '0' instead it works perfectly. Here is the code:


public void AssignVacancies(DateTime vStartDate, DateTime vEndDate, ArrayList vCurrentAssessorList, int vArrayIndex)
{
DAEventList.SelectCommand.Parameters["@pID"].Value = vCurrentAssessorList[vArrayIndex].CommandID;

DAEventList.SelectCommand.Parameters["@pPrecedence"].Value = vCurrentAssessorList[vArrayIndex].Precedence;


Any ideas?
 
Here is an example how to use the ArrayList and it is working:
//declaration and creation
private ArrayList m_itemsArray = new ArrayList();

// how to populate the ArrayList object
private void AddItemsToArray(String sFirst , String sLast, int iAge)
{
ArrayList arr = new ArrayList();
arr.Add(sFirst );
arr.Add(sLast);
arr.Add(iAge);
m_itemsArray.Add(arr);
}

// how to iterate and extract

private void CreateNodes()
{
for(int i = 0; i <= m_itemsArray.Count -1 ; i++)
{
ArrayList selArr = (ArrayList)m_itemsArray;
String sFirst = (String)selArr[0];
String sLast = (String)selArr[1];
int iAge = (int)selArr[2];
....
}
}
Good luck!

 
slatet -
How are you calling AssignVacancies?

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top