title: Resolving an IP address from DNS in C#
body: <p>I am trying to make a TCP socket connection to an IP address. I can do this by directly parsing an IP address like this:</p>
  
  <pre><code>IPAddress ipAddress = IPAddress.Parse("192.168.1.123");
  IPEndPoint remoteEP = new IPEndPoint(ipAddress, 80);
  // Create a TCP/IP  socket.
  Socket sender = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);  // This works!
  </code></pre>
  
  <p>However, I cannot figure out how to divine this IP address from a DNS string.  I've tried every combination of the following:</p>
  
  <pre><code>IPAddress ipAddress = Dns.Resolve("www.mydns.org");   // No dice
  IPAddress ipAddress = Dns.GetHostEntry("www.mydns.org");  // Nada
  IPAddress ipAddress = IPAddress.Parse(Dns.Resolve("www.mydns.org"));   // So many errors...
  IPAddress ipAddress = IPAddress.Parse(Dns.Resolve("www.mydns.org").toString());  // WTh is this attempt anyway?
  </code></pre>
  
  <p>Would any of you kind souls have a tip to help me squeeze an IPAddress out of a DNS?</p>