xxxxxxxxxx
string input = "hello/world/how/are/you";
char separator = '/';
int index = input.IndexOf(separator);
if (index >= 0)
{
string first = input.Substring(0, index);
string second = input.Substring(index + 1);
Console.WriteLine($"First: {first}");
Console.WriteLine($"Second: {second}");
}
xxxxxxxxxx
Considerar somente a primeira string especificada para realizar o split
You can specify how many substrings to return using string.Split:
string myString = "101.a.b.c.d"
var pieces = myString.Split(new[] { '.' }, 2);
Returns:
101
a.b.c.d