How to find the IP address of a hostname in C#

1 Answer

0 votes
using System.Net;

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

        private void button1_Click(object sender, EventArgs e)
        {
            string HostName = "www.seek4info.com";
            IPAddress[] ipaddress = Dns.GetHostAddresses(HostName);

            foreach (IPAddress address in ipaddress)
            {
                MessageBox.Show($"    {address}");
            }
        }
    }
}



/*
run:

43.28.74.184
 
*/

 



answered Jun 5, 2024 by avibootz

Related questions

1 answer 105 views
1 answer 187 views
2 answers 182 views
1 answer 106 views
4 answers 247 views
247 views asked May 15, 2024 by avibootz
2 answers 170 views
1 answer 187 views
187 views asked May 6, 2021 by avibootz
...