title: Display IP Addresses in a Rich text box
body: <p>I have a problem with a C# Application I am making. I am trying to get all IPs to display in a textbox within a windows form by simply clicking a button. I currently have a base to work with: </p>
  
  <pre><code>    private void btnIP_Click(object sender, EventArgs e)
      {
           NetworkInterface[] ipadapters = NetworkInterface.GetAllNetworkInterfaces();
          string iptemplate = @"
          Network adapter: {0}
          IP:              {1}";
  
          string IPText = "";
  
          foreach (NetworkInterface AdapterIP in ipadapters)
          {
  
              IPText = IPText + String.Format(iptemplate,
              AdapterIP.Name,
              AdapterIP = ipadd());
  
          }
              txtOutput.Text = IPText;
          }
  </code></pre>
  
  <p>However, I am just not understanding whether I can do this using the </p>
  
  <p><code>using System.Net.NetworkInformation;</code></p>
  
  <p>If someone can just explain to me how I can take IPs from there and display it, it would help a lot. I have seen people query DNS to retrieve a hostname etc, but I just want to show all IPv4 and IPv6 addresses for all adapters.</p>
  
  <p>I am just not understanding it. I know that I need to keep the foreach() method but not sure how to build out this code to make it work. Note: I have it working for a descriptions and everything for all adapters but I've created a separate button solely dedicated to IPs. </p>