How to get string

Total Post:33

Points:231
C# 
C#
 1532  View(s)
Ratings:
Rate this:
string str="xyz,abcd,pqrst,123456"

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

How???
Please help me...
  1. 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 Apr-04-2018 01:43:16 AM
  1. Post:36

    Points:260
    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. Post:33

    Points:231
    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;
         }
      }

      Modified On Apr-04-2018 01:43:51 AM
  1. Post:33

    Points:231
    Re: How to get string

    Thanks, Mr Pawan & Mr Abhishek

Answer