c#使用richtextbox查找文本rtb。查找并使用as复选框

c#使用richtextbox查找文本rtb。查找并使用as复选框,c#,text,find,C#,Text,Find,大家好,有人能告诉我正确的语法吗?我不会找到“核心”这个词,运行一些代码,或者在richtexbox中找到“业务”这个词,运行一些代码 因此,我的richtextbox将具有类似c:\core\app1\ver\name的文本 { string core = "Core"; string business = "Business"; if richTextBox2.Find(core); {

大家好,有人能告诉我正确的语法吗?我不会找到“核心”这个词,运行一些代码,或者在richtexbox中找到“业务”这个词,运行一些代码

因此,我的richtextbox将具有类似c:\core\app1\ver\name的文本

 {
            string core = "Core";
            string business = "Business";

           if  richTextBox2.Find(core);
            {
                MessageBox.Show ("Found Core");
            }
            else
            {
                MessageBox.Show ("Found Business");
            }
        }

使用richtextbox的文本属性:

if(richTextBox2.Text.Contains("Core"))
{
    MessageBox.Show("Found Core");
}
if(richTextBox2.Text.Contains("Business"))
{
    MessageBox.Show("Found Business");
}
您可以使用“else if”,但如果您的richtextbox包含core、business或两者,上述内容将提醒您