How to extract the domain name from an email address in C#

1 Answer

0 votes
using System;
using System.Net.Mail;

class Program
{
    static void Main() {
        MailAddress email = new MailAddress("username@email.com");
        
        string domain_name = email.Host;;

        Console.Write(domain_name);
    }
}


 
 
 
 
/*
run:
 
email.com
 
*/

 



answered Apr 29, 2022 by avibootz

Related questions

1 answer 163 views
1 answer 154 views
1 answer 190 views
1 answer 149 views
2 answers 355 views
...