How to get hostname based on IP address 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 IPAddress = "43.123.81.117";
            
            IPHostEntry hostEntry = Dns.GetHostEntry(IPAddress);

            MessageBox.Show(hostEntry.HostName);
        }
    }
}



/*
run:

abcdefgzyz.com
 
*/

 



answered Jun 5, 2024 by avibootz

Related questions

1 answer 113 views
1 answer 187 views
2 answers 170 views
1 answer 175 views
175 views asked Feb 21, 2019 by avibootz
2 answers 201 views
201 views asked Jun 23, 2016 by avibootz
...