Built-in method to validate email address in C#

Published on February 10, 2016 by abundantcode

Filed under Regular Expressions

Last modified February 9, 2016

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 1529 times

Are you looking for a built-in method in C# which lets you validate email address. If yes , you can use the EmailAddressAttribute class that is defined in the System.ComponentModel.DataAnnotations namespace to do it.

How to validate email address in C# using EmailAddressAttribute class ?

Below is a sample code snippet demonstrating the usage of the EmailAddressAttribute class to validate the email address in C#.

using System;
using System.ComponentModel.DataAnnotations;

namespace ACCode
    class Program
        static void Main(string[] args)
            EmailAddressAttribute validator = new EmailAddressAttribute();
            var result1 = validator.IsValid("test@gmail");
            var result2 = validator.IsValid("test@gmail.com");
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

1 Comment

  1. Ginktage – Community Blog Posts – February 10 , 2016 | Ginktage
    February 10, 2016 - 9:28 pm

Leave a Comment