gpt4 book ai didi

c# - 正则表达式类 - 缺少程序集引用?

转载 作者:太空宇宙 更新时间:2023-11-03 10:45:35 26 4
gpt4 key购买 nike

我正在定义一个新类。两个问题:

Match m = Regex.Match(text, pattern, RegexOptions.IgnoreCase, TimeSpan.FromSeconds(1));

出现此错误:“方法‘Match’没有重载需要 4 个参数”。但是 MSDN 用 4 个参数定义了这个。

catch (RegexMatchTimeoutException)

出现此错误:“找不到类型或命名空间名称‘RegexMatchTimeoutException’(是否缺少 using 指令或程序集引用?)”

我的使用指令:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

我正在使用 .NET4.5 运行 VS2008Express

最佳答案

仅在 .NET 4.5 中引入了带有 4 个参数的 Match 方法的重载。问题是,您不能使用 Visual Studio 2008 开发 .NET 4 及更高版本的应用程序。参见 ScottGu's Blog :

There isn't any way to target .NET 4 from VS08 and use new features. Having said that, .NET4 is upwards comaptible with .NET 3.5 - so applications you build targeting .NET 3.5 with VS08 should work fine on top of .NET 4.

另外,查看 this question .

关于c# - 正则表达式类 - 缺少程序集引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23533517/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com