How can I split a C# string based on the first occurrence of the specified character? Suppose I have a string with value:
101,a,b,c,d
I wa
You can use Substring to get both parts separately.
First, you use IndexOf to get the position of the first comma, then you split it :
string input = "101,a,b,c,d";
int firstCommaIndex = input.IndexOf(',');
string firstPart = input.Substring(0, firstCommaIndex); //101
string secondPart = input.Substring(firstCommaIndex + 1); //a,b,c,d
On the second part, the +1 is to avoid including the comma.