Home > DeveloperSection > Forums > How to get string
Manmohan Jha

Total Post:35

Points:245
Posted on    January-24-2014 2:51 AM

 C# C# 
Ratings:


 4 Reply(s)
 974  View(s)
Rate this:
string str="xyz,abcd,pqrst,123456"

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

How???
Please help me...


Abhishek Singh

Total Post:8

Points:56
Posted on    January-24-2014 7:42 AM

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]);
            }

Modified On Jan-24-2014 07:54:56 AM

Pawan Shukla

Total Post:37

Points:267
Posted on    January-24-2014 7:52 AM

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]);
            }


Manmohan Jha

Total Post:35

Points:245
Posted on    January-24-2014 11:04 PM

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;
     }
  }

Manmohan Jha

Total Post:35

Points:245
Posted on    January-25-2014 12:36 AM

Thanks, Mr Pawan & Mr Abhishek

Don't want to miss updates? Please click the below button!

Follow MindStick