I have the following code:
Dim ipAdd As IPAddress = Dns.GetHostEntry(strHostname).AddressList(0) Dim strIP As String = ipAdd.ToString()
When I
Instead of unconditionally taking the first element of the AddressList, you could take the first IPv4 address:
var address = Dns.GetHostEntry(strHostname) .AddressList .First(ip => ip.AddressFamily == AddressFamily.InterNetwork);