Hi
I have code which is printing :: 1 but i want that it should be converted to IP IV
Thanks
Hi
I have code which is printing :: 1 but i want that it should be converted to IP IV
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jithu ThomasRank #437 · 5.7K reputationPosted Jan 21, 2024, 2:43 AM EST
using System; using System.Net; using System.Net.Sockets; public class IPv4String { public static void Main() { string ipv4String = GetIPv4Address(); Console.WriteLine("IPv4 Address: " + ipv4String); } public static string GetIPv4Address() { string ipv4 = string.Empty; foreach (IPAddress ip in Dns.GetHostAddresses(Dns.GetHostName())) { if (ip.AddressFamily == AddressFamily.InterNetwork) { ipv4 = ip.ToString(); break; } } return ipv4; } }please check with this code.
please accept the answer if it is useful.