In my App the user could manually enter some host computer location
for this he has the choice to enter either the IP or host name.
I get the IP address internally with the following code sample:
IPAddress ia;
try
{
ia = IPAddress.Parse (host);
}
catch(FormatExc eption)
{
IPHostEntry he = Dns.GetHostByNa me( host );
ia = he.AddressList[0];
}
I wonder if there is another way to do that which would avoid the try catch,
any tips ?
for this he has the choice to enter either the IP or host name.
I get the IP address internally with the following code sample:
IPAddress ia;
try
{
ia = IPAddress.Parse (host);
}
catch(FormatExc eption)
{
IPHostEntry he = Dns.GetHostByNa me( host );
ia = he.AddressList[0];
}
I wonder if there is another way to do that which would avoid the try catch,
any tips ?
Comment