Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / VB

Whats My IP Address ?

4.75/5 (5 votes)
14 Sep 2011CPOL 9.9K  
namespace IpAddresses{ using System; using System.Collections.Generic; using System.Linq; using System.Net; class Program { static void Main(string[] args) { GetIPAddresses().ForEach(ip => Console.WriteLine(ip)); } ...
C#
namespace IpAddresses
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;

    class Program
    {
        static void Main(string[] args)
        {
            GetIPAddresses().ForEach(ip => Console.WriteLine(ip));
        }

        static List<string> GetIPAddresses()
        {
            return Dns.GetHostAddresses(Dns.GetHostName()).Select(ipAddress => ipAddress.ToString()).ToList<string>();
        }
    }
}


:)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)