CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Posts
    7

    How can I dynamically increase an array in C#

    or delete a part of it, similar to C++: CArray.Add()/RemoveAt().
    Through ArrayList and using Buffer.BlockCopy I can double it but what about removing a part of it.
    Last edited by ser; January 30th, 2005 at 08:05 PM. Reason: 1

  2. #2
    Join Date
    Dec 2004
    Posts
    7

    Re: How can I dynamically increase an array in C#

    sorry, I think I've found a solution. Queue method looks like exceeding my requirements.

  3. #3
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Post Re: How can I dynamically increase an array in C#

    What is wrong about ArrayList? I think it is the right class for you. Or do you want the array to physicaly cut allocated memory if removing elements? This is not good demand. If memory is already allocated to the array, it cost nothing to keep it allocated event empty. Shrinking the allocated memory is unnecessary overhead, because, the managed memory has to be reorganized.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured