> Yes but I was hoping to check the string without having to add the overhead
> of an exception. The majority of the time it will be a DNS host name not an
> IP address.
When you talk about the overhead of the exception, just how many of
these are you doing? See
http://www.pobox.com/~skeet/csharp/exceptions.html
It would be reasonably easy to hard-code a test, and feasible to do as
a regular expression (the tricky bit is rejecting 300.300.300.300 but
allowing 30.30.30.255 etc). The *simplest* way is probably to use
IPAddress.Parse though. Whether this counts as an abuse of exceptions
is a matter of taste IMO. Note that in .NET 2 you'll be able to use
IPAddress.TryParse, which is much more what you're after.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Kevin Spencer - 30 Sep 2005 21:53 GMT
The 2.0 Platform has a TryParse for the IPAddress, and a number of other
classes as well. It doesn't throw an exception. Unfortunately, the 1.1
platform does not.

Signature
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Big things are made up of
lots of little things.
>> Yes but I was hoping to check the string without having to add the
>> overhead
[quoted text clipped - 12 lines]
> is a matter of taste IMO. Note that in .NET 2 you'll be able to use
> IPAddress.TryParse, which is much more what you're after.