Sounds like it would be easier to have two arrays...
String[] PackName;
Int[] PackCount;
Just not as tidy as using the Stuct.
"Lasse Vågsæther Karlsen" <la***@vkarlsen.no> wrote in message
news:Xn*****************************@207.46.248.16 ...
"Ollie" <ol**********@hotmail.com> wrote in
news:OD**************@TK2MSFTNGP10.phx.gbl:
OK, What I need to do is count Packs. I don't know the PackName nor do
I know how many there are. What I do know that there are multiple
instances of the same PackName.
So, What I want to do is create a dynamic array of Packs and add these
to the array. Where the PackName already exists I just want to
increment the PackCount for the corresponding PackName.
Hope that makes sense.
<snip>
Use a hashtable
Hashtable list = new Hashtable();
// add XYZ to the list
if (list.Contains("XYZ"))
list["XYZ"] = (Int32)list["XYZ"] + 1;
else
list["XYZ"] = 1;
this will add XYZ to the list with a value of 1, if it's not already
there. If it's there, read out the previous value, increment it by 1 and
store it back into the list.
Of course, if you need to store more than a Int32 value for each name,
you should create a class to hold the various values.
--
Lasse Vågsæther Karlsen
la***@vkarlsen.no
PGP KeyID: 0x0270466B