Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Tagged as

Whats My IP Address ?

, 14 Sep 2011
Rate this:
Please Sign up or sign in to vote.
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)); } ...
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>();
        }
    }
}
 
Smile | :)

License

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

Share

About the Author

Mohammad A Rahman
Software Developer
Australia Australia
Designer and Architect.
Author of the Expert C# 5.0: with the .NET 4.5 Framework book

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 14 Sep 2011
Article Copyright 2011 by Mohammad A Rahman
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid