چک کننده ایمیل در سی شارپ

یک textBox و یک دکمه را بر روی فرم قرار دهید. با دو بار کلیک بر روی دکمه به محیط کدنویسی رفته و کدهای زیر را وارد نمایید :

using System;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace Emailchecker
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Regular Expression
            Regex regex1 = new Regex("^[a-zA-Z]+[a-zA-Z0-9]+[[a-zA-Z0-9-_.!#$%'*+/=?^]{1,20}@[a-zA-Z0-9]{1,20}.[a-zA-Z]{2,3}$");
            //This function will check whether the expression is right or not.

            if (!regex1.IsMatch(textBox1.Text))
            {
                MessageBox.Show("Your email address format is not correct!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("Congratulations Your email address format is correct!", "CORRECT", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }     
        }
    }
}

حال در داخل textBox یک آدرس ایمیل وارد کرده و بر روی دکمه کلیک و نتیجه را مشاهده نمایید.
منبع :http://www.c-sharpcorner.com