471,350 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

How to remove item from 1 d array

Hi
..net 1.1
I have a simple string array like
string[] myArray = CallToWebServiceThat_Returns_Elements;

I want to remove an item from the array and also remove its position.
I can search the array and find the index of desired string, but how
can I remove?

Do I have to somehow create a new array that is smaller and then copy
everything over except the value that I want?
Is there some utility to do this?

Thanks
jeff
Feb 15 '06 #1
1 5589
Jeff User <je*******@hotmail.com> wrote:
.net 1.1
I have a simple string array like
string[] myArray = CallToWebServiceThat_Returns_Elements;

I want to remove an item from the array and also remove its position.
I can search the array and find the index of desired string, but how
can I remove?
You can't. Arrays are fixed size.
Do I have to somehow create a new array that is smaller and then copy
everything over except the value that I want?
Is there some utility to do this?


An easier way of working is to use ArrayList or List<string> if you're
using .NET 2.0.

However, Array.Copy helps you with the array copying part. You could
write helper methods to deal with the rest if you need to do it often.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 15 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Patrick G. | last post: by
12 posts views Thread by Sam Collett | last post: by
3 posts views Thread by Jeremy | last post: by
4 posts views Thread by None | last post: by
6 posts views Thread by tedpottel | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.