C# Identify the Available Serial Port on the PC

With this sample code, you can identify the available serial port on the PC. Running a ForEach iteration on the SerialPortNames property in vb.net and GetPortNames method in C#.

Sample code for C#:

private void  BtnFindSerialPort_Click(object sender, EventArgs e) 
{ 
     foreach (string ports in System.IO.Ports.SerialPort.GetPortNames()) 
     { 
         MessageBox.Show("Serial port avialible" + " "  + ports); 
     } 
}