Skip to content

Matching--> please reply

Santhosh K S

Asked Apr 19, 2012, 7:55 PM EDT1 answer
Share
LinkedInX
I'm new to C#, Array list having Some string , when i enter tec=xt into Textbox ,if the string present in beganing of array list string, then that array sholud display that nly matching text in arraylist elements

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Senthilkumar
    0
    Hi,

    I am not sure..but you are looking some thing like this.

            //Store the Text box value into variable.
            string txtValue = Text1.Text;
            ArrayList list = new ArrayList();
            list.Add("ONE");
            list.Add("TWO");
            list.Add("THREE");
            //
            // Loop over ArrayList with for.
            //
            for (int i = 0; i < list.Count; i++)
            {
                string value = list[i] as string;
                if (value.Contains(txtValue))
                {
                    Console.WriteLine("Position:{0} and text is {1}", i.ToString(), value);
                }
            }

    Hope this help you.
    0