I need an email validator in C#... i never written a letter C#...

i found this:

public static bool isEmail(string inputEmail)
{
   inputEmail  = NulltoString(inputEmail);
   string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
         @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + 
         @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
   Regex re = new Regex(strRegex);
   if (re.IsMatch(inputEmail))
    return (true);
   else
    return (false);
}

but do i need to import Regex or something?

thanks!

Edited 3 Years Ago by pritaeas: Fixed formatting

If you just have this one, suggest you translate it to VB!
e.g. the line
Regex re = new Regex(strRegex);
would translate to
Dim re As New Regex(strRegex)
etc.

it's a task for school.. it HAS to be C#
looking already for days

a suggestion that i found is create another project only in C#and import the .dll file in my vb.net project..

other possibilities?

a suggestion that i found is create another project only in C#and import the .dll file in my vb.net project..

Under .NET you can as easily import a dll written in VB in C# as you can do the opposite, so go ahead if it HAS to be C#. I believe that is part of this learning exercise.

thanks for the help i found the solution:

create csharp project
make class with above a namespace ...
build it
in vb.net project add the reference
then import namespace ...
and ready to go!

This article has been dead for over six months. Start a new discussion instead.