Question: In a C# program, take an IPv4 address provided by the user, and return the hostname for that IPv4 address. I have come a decent
In a C# program, take an IPv4 address provided by the user, and return the hostname for that IPv4 address. I have come a decent way but my code will only return: System.Net.IPHostEntry. Here is a copy of my code:
string ip;
Console.WriteLine("Please enter an IPv4 address: ");
ip = Console.ReadLine();
IPAddress address = IPAddress.Parse(ip);
IPHostEntry hostInfo = Dns.GetHostEntry(address);
Console.WriteLine(hostInfo);
Like I said, I need the code to essential accept an IP address and return the hostname for that address. So if the user enters: 74.125.136.102, the program should display: google.com.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
