加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式不是有效的类型或命名空间C#

发布时间:2020-12-14 02:30:24 所属栏目:百科 来源:网络整理
导读:我正在尝试将此代码段添加到我的代码中: public string Highlight(string InputTxt){ string Search_Str = txtSearch.Text.ToString(); // Setup the regular expression and add the Or operator. Regex RegExp = new Regex(Search_Str.Replace(" ","|").T
我正在尝试将此代码段添加到我的代码中:
public string Highlight(string InputTxt)
{
    string Search_Str = txtSearch.Text.ToString();

    // Setup the regular expression and add the Or operator.
    Regex RegExp = new Regex(Search_Str.Replace(" ","|").Trim(),RegexOptions.IgnoreCase);

    // Highlight keywords by calling the 
    //delegate each time a keyword is found.
    return RegExp.Replace(InputTxt,new MatchEvaluator(ReplaceKeyWords));

    // Set the RegExp to null.
    RegExp = null;
}

但是,由于某种原因,“Regex”没有显示 – 找不到类型或命名空间.我想我必须使用更新版本的C# – 任何人都可以用更新的方式来帮我解决这个问题吗?我使用的是System.Text.RegularExpressions.Regex – 也许他们完全摆脱了它?

using System.Text.RegularExpressions;

尝试该命名空间.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读