Ipaddress.address -> ip format 255.255.255.255

How do I get an ip format of 255.255.255.255 from

IPHostentry iph = Dns.Resolve(hostname.com);
string a = iph.AddressList[0].Address.ToString(); // gives me a long number, how do i get the above format?
LVL 1
addicktzAsked:
Who is Participating?
 
SmithJWCommented:
use this instead, the functions you have attempted to use are deprecated:

IPHostEntry iph = Dns.GetHostEntry("hostname.com");
string a = iph.AddressList[0].ToString();
0
 
AdGrootCommented:
if you use dotnet framework 2.0 use this  


          foreach (IPAddress adr in Dns.GetHostAddresses("localhost"))
            {
                MessageBox.Show(adr.ToString());
            }

Dns.GetHostEntry("hostname.com"); is obsolute in framework 2.0

Ad
0
 
SmithJWCommented:
I'm using framework 2.0
I didn't get any messages that it was obsolete, but I didn't check, both methods work though :)
0
 
AdGrootCommented:
Sorry

I was wrong, made a copy error

Dns.Resolve(hostname.com); this one was obsolute

Ad
 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.