Код: Выделить всё
static string[] Split(string str, string delim)
{
if (!str.Contains(delim))
{
return new string[] { str };
}
else
{
//initialize a list of type string
var lst = new List();
//use a string builder to get characters
var strbuilder = new StringBuilder();
foreach(var ch in str)
{
if (!ch.ToString().Equals(delim))
{
strbuilder.Append(ch);
}
else
{
//append the current string to the list
lst.Add(strbuilder.ToString());
//clear the string builder
strbuilder.Clear();
}
}
return lst.ToArray();
}
}
//usage
var lst = Split("The-quick-brown-fox-jumps-over-the-lazy-dog", "-");
foreach(var str in lst)
{
Console.WriteLine(str);
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... last-strin
Мобильная версия