any one know how to search a string array for a particular value a then remove it from there without keeping a null element to find the element where the value exists and then to remove the element

Please if any one know how to do it give me an example

Look on this site for more information and examples, because I don't really get what it is you are saying.

lets say there is a string array that have 3 values

p001
p002
p005

i want the value p002 to be removed from the array
but i want to do this at the run time so i don't know the which value is in which element so i need a way when i give the value p002 it should be searched in the array and if it exists it should removed from the array

Use ArrayList class

do u have any examples

ArrayList arrayList=new ArrayList();
//following code can be used to add items  to array
 arrayList.Add("poo1");
void RemoveString( object pobj)//you can change parameter type 
{
   arrayList.Remove(pobj);
}
commented: not a bad example +1

It is better to use the generic List type:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> MyList = new List<string>();
            MyList.Add("p001");
            MyList.Add("p002");
            MyList.Add("p003");
            for (int i = 0; i < MyList.Count; i++)
            {
                Console.WriteLine(MyList[i]);
            }
            MyList.Remove("p002");
            Console.WriteLine("#################### After removing:");
            for (int i = 0; i < MyList.Count; i++)
            {
                Console.WriteLine(MyList[i]);
            }
            Console.ReadKey();
        }
    }
}
commented: Good example! +1
commented: Generics++ +10

It is better to use the generic List type:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> MyList = new List<string>();
            MyList.Add("p001");
            MyList.Add("p002");
            MyList.Add("p003");
            for (int i = 0; i < MyList.Count; i++)
            {
                Console.WriteLine(MyList[i]);
            }
            MyList.Remove("p002");
            Console.WriteLine("#################### After removing:");
            for (int i = 0; i < MyList.Count; i++)
            {
                Console.WriteLine(MyList[i]);
            }
            Console.ReadKey();
        }
    }
}

Also known as a "Collection" and darn you for getting up earlier than me and mentioning it first :P

But yes, your best bet is what ddanbe said as it dynamically increases it's size as items are added to it and can have items removed from it, reducing it's size dynamically, without having to insert null values as placeholders to overwrite them.

Don't forget to mark the thread solved once your issue is resolved :)

commented: You got to live in Belgium ! :) +7

thank you every one

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.