I am trying to create an arrayList that contains multiple arrayLists.
My code attempt is below. The question I have is how can I get away
from creating another pAttribute list than can be added to pItem.
As I understand it (and I coded it to test) if I try to use pAttribute again
by clearing with pAttribute.Clea r because it is a shallow copy the
pItem[0] is also cleared. I guess I need a "deep copy" but can't find
any documentation on it.
So is there any way to pItem[1].Add({100.00,20 0.00}). This will not compile
but
it shows what I want to do.
I might add that I want to use ArrayList because you are not restricted to
one type
as in arrays.
thanks
grs
static void Main(string[] args)
{
ArrayList pItem = new ArrayList();
ArrayList pAttribute = new ArrayList();
for (int i = 101; i < 105; i++)
{
pAttribute.Add( i);
}
pItem.Add(pAttr ibute);
PrintValues((Ar rayList)pItem[0]);
}
public static void PrintValues(Arr ayList myList)
{
IEnumerator myEnumerator = myList.GetEnume rator();
while (myEnumerator.M oveNext())
Console.WriteLi ne(myEnumerator .Current);
}
}
My code attempt is below. The question I have is how can I get away
from creating another pAttribute list than can be added to pItem.
As I understand it (and I coded it to test) if I try to use pAttribute again
by clearing with pAttribute.Clea r because it is a shallow copy the
pItem[0] is also cleared. I guess I need a "deep copy" but can't find
any documentation on it.
So is there any way to pItem[1].Add({100.00,20 0.00}). This will not compile
but
it shows what I want to do.
I might add that I want to use ArrayList because you are not restricted to
one type
as in arrays.
thanks
grs
static void Main(string[] args)
{
ArrayList pItem = new ArrayList();
ArrayList pAttribute = new ArrayList();
for (int i = 101; i < 105; i++)
{
pAttribute.Add( i);
}
pItem.Add(pAttr ibute);
PrintValues((Ar rayList)pItem[0]);
}
public static void PrintValues(Arr ayList myList)
{
IEnumerator myEnumerator = myList.GetEnume rator();
while (myEnumerator.M oveNext())
Console.WriteLi ne(myEnumerator .Current);
}
}
Comment