我需要一個句子,所有句子都在一行中,沒有空格,每個新詞都有一個字母EX。 「StopAndSmellTheRoses」,然後將其轉換爲「停止並聞到玫瑰」這是我的函數,但我一直在插入方法的參數超出範圍錯誤。感謝您提前提供任何幫助。C#修復語句
private void FixSentence()
{
// String to hold our sentence in trim at same time
string sentence = txtSentence.Text.Trim();
// loop through the string
for (int i = 0; i < sentence.Length; i++)
{
if (char.IsUpper(sentence, i) & sentence[i] != 0)
{
// Change to lowercase
char.ToLower(sentence[i]);
// Insert space behind the character
// This is where I get my error
sentence = sentence.Insert(i-1, " ");
}
}
// Show our Fixed Sentence
lblFixed.Text = "";
lblFixed.Text = "Fixed: " + sentence;
}
這個工作我看着更進建設者,這是挑釁的路要走。非常感謝 – amedeiros 2012-03-25 15:33:18