Gopi Asai

Gopi Asai

  • NA
  • 197
  • 0

Split the string and stored into array

Aug 11 2012 2:40 AM
Hi Friends,

I want to split the string after read from INI file. Below is my code.

I have read the line from INI file that which contain the keyword "ABC" at the starting position. Here i want to read the element of ABC that "i,a,s". I can able to read this but the first value shows along with the keyword "ABC". I don't want this. I need only the values. Could anyone help me.

            string line;
            string charname = string.Empty;
            StreamReader file = new

            System.IO.StreamReader(@"H:\Dotnet Practice\INI\INI\bin\Debug\emp.ini");
            {
                while ((line = file.ReadLine()) != null)
                {
                    if (line.StartsWith("ABC"))
                    {
                        //string[] fullName = line.Split('=');
                       // charname = fullName[1];

                            string[] splitcharname = line.Split(',');

                            foreach (string splitchar in splitcharname )
                            {
                                MessageBox.Show(splitchar);

                               // if (splitchar == textBox1.Text)
                               // {
                               //     MessageBox.Show("not allowed");
                               // }
                                //break;
                            }
                    }
                }

INI file input:

ABC=i,a,s

output should be:

i
a
s

Please help me

Regards,
Gopi A

Answers (2)