Dynamic memory allocation for an array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vicky

    Dynamic memory allocation for an array

    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?
  • Marc Gravell

    #2
    Re: Dynamic memory allocation for an array

    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<intlist = new List<int>();
    list.Add(123);
    list.Add(456);

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

    Marc

    Comment

    Working...