IP address is known as an Internet Protocol address. It is a unique address that identifies the device over the network. It is almost like a set of rules which govern the data sent over the Internet or through a local network. It helps the Internet to distinguish between routers, computers, websites, etc. In this article, we are going to learn how to find the IP Address of the Machine using C#.
Helping Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net; //Include this namespace
namespace IpAddress
{
class Program
{
static void Main(string[] args)
{
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
Console.WriteLine(hostName);
// Get the IP
string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString();
Console.WriteLine("My IP Address is :"+myIP);
Console.ReadKey();
}
}
}






0 comments:
Post a Comment