Hi Worel.
Try this solution from Tom Archer and Andrew Whitechapel:
using System;
using System.Net;
class Workstation
{
public Workstation()
{
IPAddress ipAddress = Dns.Resolve(HostName).AddressList[0];
IPAddressString = ipAddress.ToString();
}
public const string HostName = "Your Machine name";
public readonly string IPAddressString;
}
class GetIpAddress
{
public static void Main()
{
Workstation workstation = new Workstation();
Console.WriteLine("The IP address for '{0}' is {1}", Workstation.HostName,
workstation.IPAddressString);
}
}