R
Richard Lionheart
Hi All,
I tried using RegEx, but the compiler barfed with "The type of namespace
'RegEx' could not be found.
Prior to this, I had the same problem with MatchCollection, but discovered
it's in the namespace "System.Text.RegularExpressions;" and that namespace
is, in turn, defined in the namespace "System", according to MSDN at
http://msdn2.microsoft.com/en-us/library/c75he57e(en-us,VS.80).aspx. So
adding "using System.Text.RegularExpressions" was sufficient to resolve this
issue. I didn't need to add any additional reference to my project.
MSDN says at the same webpage that RegEx is in the
"System.Text.RegularExpressions" namespace, just like MathCollection. So
why do I have a problem with it?
The program is listed below.
**More generally**, what's the best way to learn for any class (1) what
namespace it's defined in; and (2) what assembly implements that namespace
and its classes?
Thanks in advance,
Richard
======= MainClass.cs ==========
using System;
using System.Text.RegularExpressions; // MatchCollection
namespace FileBrowser
{
class MainClass
{
[STAThread]
static void Main(string[] args)
{
string sText = "When one + two = twenty";
string sPat = "(/\\w*w\\w*/)*";
MatchCollection mc;
mc = RegEx.Matches (sText, sPat);
Console.WriteLine("Count = (0)", mc.Count);
}
}
}
I tried using RegEx, but the compiler barfed with "The type of namespace
'RegEx' could not be found.
Prior to this, I had the same problem with MatchCollection, but discovered
it's in the namespace "System.Text.RegularExpressions;" and that namespace
is, in turn, defined in the namespace "System", according to MSDN at
http://msdn2.microsoft.com/en-us/library/c75he57e(en-us,VS.80).aspx. So
adding "using System.Text.RegularExpressions" was sufficient to resolve this
issue. I didn't need to add any additional reference to my project.
MSDN says at the same webpage that RegEx is in the
"System.Text.RegularExpressions" namespace, just like MathCollection. So
why do I have a problem with it?
The program is listed below.
**More generally**, what's the best way to learn for any class (1) what
namespace it's defined in; and (2) what assembly implements that namespace
and its classes?
Thanks in advance,
Richard
======= MainClass.cs ==========
using System;
using System.Text.RegularExpressions; // MatchCollection
namespace FileBrowser
{
class MainClass
{
[STAThread]
static void Main(string[] args)
{
string sText = "When one + two = twenty";
string sPat = "(/\\w*w\\w*/)*";
MatchCollection mc;
mc = RegEx.Matches (sText, sPat);
Console.WriteLine("Count = (0)", mc.Count);
}
}
}