该程序在用户键入时计算并显示字数和字符数。“字数计数器”工作正常,但我不知道如何计算字符而不计算其间的空格。
private void userTextBox_TextChanged(object sender, EventArgs e)
{
string userInput = userTextBox.Text;
userInput = userInput.Trim();
string[] wordCount = userInput.Split(null);
//Here is my error
string[] charCount = wordCount.Length;
wordCountOutput.Text = wordCount.Length.ToString();
charCountOutput.Text = charCount.Length.ToString();
}