C# 如何仅解析当前的字母/字符?

C# 如何仅解析当前的字母/字符?,c#,winforms,C#,Winforms,守则: private void richTextBox1_MouseMove(object sender, MouseEventArgs e) { // Obtain the character index where the user clicks on the control. int positionToSearch = richTextBox1.GetCharIndexFromPosition(new Point(e.X, e.Y)); string word

守则:

private void richTextBox1_MouseMove(object sender, MouseEventArgs e)
{
    // Obtain the character index where the user clicks on the control.
    int positionToSearch = richTextBox1.GetCharIndexFromPosition(new Point(e.X, e.Y));
    string word = richTextBox1.Text.Substring(positionToSearch);
    words.Add(word); // to get the specific word the mouse is on !
}
问题是,列表中的每个单词在结尾之前还包含文件的其余内容。 当鼠标在richTextBox中时,我希望列表中有字母/字符 当有空格/r/n和文件的其余内容时,每次我移动一个单词

这是单词列表内容的一个示例:

例如,在索引0中,我看到:

Satellite Weather Europe, Weather Forecast, Rainfall, Clouds, Sun in Europe - Source: SAT24.com" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta 

欧洲卫星天气,天气预报,降雨,云层,欧洲的太阳-来源:SAT24.com“/>看看这是否有帮助,这只抓住了当前的特征

// Obtain the character index where the user clicks on the control.
int positionToSearch = richTextBox1.GetCharIndexFromPosition(new Point(e.X, e.Y));
char currentChar = richTextBox1.Text[positionToSearch];// Get the character the cursor is on.
words.Items.Add(currentChar); // Add the current character to our list.
如果(positionToSearch>-1){string word=richTextBox1.Text.Substring(positionToSearch,1);…}
,您会发现将集合从字符串更改为字符更有用。
// Obtain the character index where the user clicks on the control.
int positionToSearch = richTextBox1.GetCharIndexFromPosition(new Point(e.X, e.Y));
char currentChar = richTextBox1.Text[positionToSearch];// Get the character the cursor is on.
words.Items.Add(currentChar); // Add the current character to our list.