Click here to Skip to main content
15,889,992 members
Articles / Programming Languages / Visual Basic
Alternative
Tip/Trick

Whats My IP Address ?

Rate me:
Please Sign up or sign in to vote.
4.75/5 (5 votes)
14 Sep 2011CPOL 9.8K   2  
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)


Written By
Software Developer
Australia Australia

Comments and Discussions

 
-- There are no messages in this forum --