我想做个串口通信,想获取本机的串口。然后赋值给combox控件。  谢谢

解决方案 »

  1.   

    msdn 中的代码:using System;
    using System.IO.Ports;namespace SerialPortExample
    {
        class SerialPortExample
        {
            public static void Main()
            {
                // 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);
                }            Console.ReadLine();
            }    }
    }
    得到名字后, 使用名字构造 SerialPort 类实例即可