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!

using System.Text.RegularExpression;
Imports System.Text.RegularExpression

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.

yes, probably it is, but it's hard without no explanation

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.