HOW TO GET STRING

Manmohan Jha

Total Post:35

Points:245
Posted by  Manmohan Jha
C# 
C#
 1208  View(s)
Ratings:
Rate this:
string str="xyz,abcd,pqrst,123456"

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

How???
Please help me...
  1. Abhishek Singh

    Post:8

    Points:56
    Re: How to get string

    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
  1. Pawan Shukla

    Post:38

    Points:274
    Re: How to get string

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

  1. Manmohan Jha

    Post:35

    Points:245
    Re: How to get string

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

  1. Manmohan Jha

    Post:35

    Points:245
    Re: How to get string

    Thanks, Mr Pawan & Mr Abhishek

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!