I need to read computers ip adress, which is already done. After that I need to change the recieved ip value to hex and then to decimal, basically like this
127.0.0.1
flip the value to 1.0.0.127
to hex 0100007F
and finally to 16777343
.
public static string GetLocalIPAddress()
{
var host = Dns.GetHostEntry(Dns.GetHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
string hexValue = ip.ToString();
string cleanAmount = hexValue.Replace(".", string.Empty);
Console.Write(cleanAmount + "\n");
return ip.ToString();
}
}
throw new Exception("No network adapters with an IPv4 address in the system!");
}
static void Main(string[] args)
{
GetLocalIPAddress();
}