validate a email

swetz 0 Tallied Votes 175 Views Share

I have written a code to validate a string.but i am getting an error in the 3rd sentence as "the name "NullToString"does not exist in the current context"...can anyone help me out...

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);
        }
Lusiphur 185 Practically a Posting Shark Team Colleague Featured Poster

Should be a Discussion Topic instead of a Code Snippet... other than that tho, on my way out the door and hopefully someone else can help you out :)

nick.crane 342 Veteran Poster

Your function is declared static.
Is NulltoString also static?

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.