using System;
using System.Text.RegularExpressions;
using System.Globalization;
public class Kata
{
public static string ToCamelCase(string str)
{
TextInfo myTI = new CultureInfo("en-US", false).TextInfo;
string clearStr = Regex.Replace(myTI.ToTitleCase(str), @"_|-", "");
return clearStr = str.Substring(0, 3) + clearStr.Remove(0, 3);
}
}
輸入 - > ToCamelCase( 「the_stealth_warrior」)System.ArgumentOutOfRangeException錯誤
輸入 - > ToCamelCase(以下簡稱 「隱身戰士」)
Error: System.ArgumentOutOfRangeException : Index and length must refer to a location within the string. Parameter name: length
我在做什麼錯?
Whay是''a「','」ab「'所需的輸出嗎? –
我剛剛試過你的代碼。它運行時不會在我的機器上拋出異常。你確定你沒有通過相同的其他值,如String.Empty? –