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; } }
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
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]);
}