- using System;
- using System.Net;
- public class ForgetCode
- {
- public static void Main()
- {
- UseDNS();
- }
- public static void UseDNS()
- {
- string hostName = Dns.GetHostName();
- Console.WriteLine("Host Name = " + hostName);
- IPHostEntry local = Dns.GetHostByName(hostName);
- foreach (IPAddress ipaddress in local.AddressList)
- {
- Console.WriteLine("IPAddress = " + ipaddress.ToString());
- }
- }
- }
Output: |
---|
Host Name = Your-PC Name |
IPAddress = Your IP address |