title: How to get a list of all available Com Ports in C# with asp.net 4
body: <p>How can I list all of the available com ports to my computer?</p>
  
  <p>I have seen a few examples wiht .net 1.1 so I was wandering is there is not a more modern way to go about doing this?</p>
  
  <p>I have my serialPort called <code>serialPort</code> </p>
  
  <p>I got this code from msdn site:</p>
  
  <pre><code>// Get a list of serial port names. 
  string[] ports = SerialPort.GetPortNames();
  
  Console.WriteLine("The following serial ports were found:");
  
  // Display each port name to the console. 
  foreach(string port in ports)
  {
      Console.WriteLine(port);
  }
  </code></pre>
  
  <p>It give me the following error:
      The name "SerialPort" Does not exist in the current context</p>
  
  <p>I have tried changing it to a small s, and I then get this error:</p>
  
  <pre><code>Member 'System.IO.Ports.SerialPort.GetPortNames()' cannot be accessed with an instance        reference; qualify it with a type name instead    
  </code></pre>