martynball
Member
- Joined
- Jul 8, 2014
- Messages
- 14
- Programming Experience
- Beginner
Okay, here is the top section of my form which includes the required namespaces?
Here is some code that checks if the email is valid.
This isn't working as it's saying:
Now it works like this:
System.Text.RegularExpressions.Regex regex
But I though that because I have included "System.Text" at the top I wouldn't need to reference all of the classes?
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
Here is some code that checks if the email is valid.
C#:
private void DoLogin_Click(object sender, EventArgs e)
{
string GetEmail = LoginEmail.Text;
System.Text.RegularExpressions.Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
Match match = regex.Match(GetEmail);
if (match.Success)
{
MessageBox.Show(GetEmail + " is correct");
}
else
{
MessageBox.Show(GetEmail + " is incorrect");
}
}
This isn't working as it's saying:
C#:
Error 1 The type or namespace name 'Regex' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Martyn Ball\documents\visual studio 2013\Projects\JamSnaps\JamSnaps\Database Testing.cs 244 62 JamSnaps
Now it works like this:
System.Text.RegularExpressions.Regex regex
But I though that because I have included "System.Text" at the top I wouldn't need to reference all of the classes?