How to get the serial port names of my computer in C#

1 Answer

0 votes
using System;
using System.IO.Ports;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // example 1
            string[] theSerialPortNames = SerialPort.GetPortNames();
            foreach (string s in theSerialPortNames)
            {
                Console.WriteLine(s);
            }

            // example 2
            foreach (string s in SerialPort.GetPortNames())
            {
                Console.WriteLine(s.ToString());
            }
        }
    }
}


answered Apr 9, 2014 by avibootz

Related questions

1 answer 247 views
247 views asked Apr 8, 2014 by avibootz
1 answer 122 views
122 views asked Jan 14, 2017 by avibootz
1 answer 165 views
165 views asked Jan 14, 2017 by avibootz
1 answer 148 views
148 views asked Jan 14, 2017 by avibootz
1 answer 184 views
184 views asked Jan 14, 2017 by avibootz
...