Код: Выделить всё
public static int[] Indexes(string text)
{
List indexes = new List();
for(int i = 0; i < text.Length; i++)
{
if(text[i] == ' ')
{
indexes.Add(i + 1);
}
}
return indexes.ToArray();
}
Код: Выделить всё
public static string TitleCase(string title, string minorWords="")
{
title = title.ToLower();
int[] indexes = new int[title.Length];
indexes = Indexes(title);
foreach(int i in indexes)
{
string sChar = new string(title[i].ToString());
title.Remove(title[i], 1);
title.Insert(i, sChar.ToUpper());
}
return title;
}
Код: Выделить всё
title.Remove(title[i], 1);
System.ArgumentOutOfRangeException: count ('1') должно быть меньше илиравен '-83'. (Параметр «count») Фактическое значение — 1.
трассировка стека:
at System.ArgumentOutOfRangeException.ThrowGreater[T](значение T, T
other, String paramName) в System.String.Remove(Int32 startIndex,
Int32 count) at Kata.TitleCase(String title, String majorWords)
at Solution.SolutionTest.MyTest(String sampleTitle, String
sampleMinorWords, ожидается строка) at
System.RuntimeMethodHandle.InvokeMethod( Цель объекта, аргументы Void**
, подпись подписи, логическое значение isConstructor) at
System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object
obj, Span`1 copyOfArgs, BindingFlags ignoreAttr)
Подробнее здесь: https://stackoverflow.com/questions/792 ... qual-to-83
Мобильная версия