Advertise with us

How to get string

string str="xyz,abcd,pqrst,123456"

Show resutl like this....
xyx
abcd
pqrst
123456

How???
Please help me...
Last updated:1/25/2014 12:36:27 AM

4 Answers

Abhishek Singh
Abhishek Singh

you need to split your String like this 

string str="xyz,abcd,pqrst,123456"
string [] arr=str.Split(',');
for (int i = 0; i < arr.Length; i++)
            {
                Console.WriteLine(arr[i]);
            }

Last updated:1/25/2014 12:36:27 AM
Pawan Shukla
Pawan Shukla

use this code                                                  

string str="xyz,abcd,pqrst,123456"
string[] value=str.Split(',');

for (int i = 0; i < value.Length; i++)
            {
                Console.WriteLine(value[i]);
            }

Last updated:1/25/2014 12:36:27 AM
Manmohan Jha
Manmohan Jha

int x = 0, j = 0;
string s="xyz,abcd,pqrst,123456";
for (int i = 0; i < s.Length; i++)
{
   if (s[i] == ',')
   {
     if (j > 0)
    {
     x = i - j;
     }
    else
    {
        x = i;
     }
     MessageBox.Show(s.Substring(j, x).ToString();
     j = i + 1;
     }
  }

Last updated:1/25/2014 12:36:27 AM

Answer