Dynamic memory allocation for an array

  • Thread starter Thread starter Vicky
  • Start date Start date
V

Vicky

I need to know how to set the size of an array at runtime (ie) a[]
should have the its size increased/decreased as its contents are added/
deleted. Can u tell me how to do it?
 
should have the its size increased/decreased as its contents are added/
deleted. Can u tell me how to do it?

Arrays are not resizeable once created; use a List<T> - i.e.
List<int> list = new List<int>();
list.Add(123);
list.Add(456);

if you need an array (copy) from this, call ToArray().

Marc
 
Back
Top