ArrayList question

  • Thread starter Thread starter keys4worship
  • Start date Start date
K

keys4worship

I am populating an arraylist from a text file on my PC. I am using this
information with C# to perform actions against a PCOM session. A for
loop handles the actions to perform. If for some reason the action
fails using one of the items in the arraylist the loop continues until
the last item in the arraylist is reached.
What I need to do is somehow annotate those items that were
successfully automated so that any items that excepted could be handled
manually.
What is the best way of handling this?
Write back to the array with a success indicator?
Write unsuccessful items to another outputfile?
???

Thanks
Steve
 
keys4worship said:
I am populating an arraylist from a text file on my PC. I am using this
information with C# to perform actions against a PCOM session. A for
loop handles the actions to perform. If for some reason the action
fails using one of the items in the arraylist the loop continues until
the last item in the arraylist is reached.
What I need to do is somehow annotate those items that were
successfully automated so that any items that excepted could be handled
manually.
What is the best way of handling this?
Write back to the array with a success indicator?
Write unsuccessful items to another outputfile?
???

I'd create another ArrayList, and when you hit an unsuccessful item,
add it to that ArrayList. Depending on your situation, you may of
course need to persist that to a file.
 
This definitely not exactly what you are looking for, but it should get you
on the right path.

private void BuildArrayList()
{
arraylist myArray = new arraylist();
// code to read in your data
while(data.read())
{
try
{
// the data I am adding is just some arbitary junk
// you will have to put in the info you want
myArray.Add(data(0));
}
catch (exception ex)
{
// this will load any items that are "automated"
// by catching the exception thrown and adding
// a handled item in the list
myArray.Add("Exception Item");
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Add to ArrayList 2
Getting at items in arraylist 7
ArrayList blues... 5
ArrayList Question 8
inconsistent ArrayList sort results 2
Custom class and ArrayList 2
Comparing ArrayLists 5
ArrayList in CSharp 3

Back
Top