问题描述
我这里有问题。我正在尝试制作一个可以打破驼峰式大小写的函数,但它似乎不起作用,因为它不会在大写单词 Console.Writeline("camelCaseExampleHere")
之后给出空格。这是它的工作原理:
static string breakCamelCase(string str) {
char[] lttrarray = str.tochararray();
//string newstr = "";
for (int i = 1; i <= lttrarray.Length-1; i++)
{
if (char.IsUpper(lttrarray[i]))
{
Console.WriteLine("CamelCase Detected at " + lttrarray[i]);
str.Insert(i," ");
//Console.WriteLine(lttrarray.ToString());
lttrarray = str.tochararray();
}
}
return new string(lttrarray);
}
但我获得的输出仍然与输入相同
CamelCase 在 C 处检测到
在 E 处检测到 CamelCase
在 H 处检测到 CamelCase
camelCaseExampleHere
我对输出的期望是:camel Case Example Here
有人知道为什么吗?我已经为此工作了一整天。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)