Pregunta

I'm defining a new class. Two issues:

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

Gives this error: "No overload for method 'Match' takes 4 arguments". But the MSDN defines this with 4 args.

catch (RegexMatchTimeoutException)

Gives this error: "The type or namespace name 'RegexMatchTimeoutException' could not be found (are you missing a using directive or an assembly reference?)"

My using directives:

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

I'm running VS2008Express with .NET4.5

¿Fue útil?

Solución

The overload of Match method which takes 4 arguments was only introduced in .NET 4.5. The problem is, you can not use Visual Studio 2008 to develop .NET 4 and later apps. See 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.

Also, check out this question.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top