0

I have this code:

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

namespace RegexTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "The quick brown fox.";
            string pat = "fox";
            Regex rgx = new Regex(pat, RegexOptions.IgnoreCase);
            Match matches = rgx.Match(str);

            Console.ReadKey();
        }
    }
}

It compiles and runs without errors.
I have a breakpoint set at Console.ReadKey(), because I wanted to inspect the variable matches.
But I got the strange error message I put in the title of this thread.
The web wasn't clear about what it meant.

So any help is as always greatly appreciated.

3
Contributors
3
Replies
12
Views
2 Years
Discussion Span
Last Post by ddanbe
0

Works fine for me in VS2013 Ultimate running .Net 4.5 console application.

I can access the matches variable and it contains fox as expected... odd.

1

Make sure you're running it in Debug mode. In Release this could have been optimised away because you're not using the variable.

Votes + Comments
Great!
0

Forgot to mention I used VS2010 Professional.
@Ketsuekiame: Indeed, forgot I stood in Release mode setting in Debug solved it!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.