码迷,mamicode.com
首页 > 其他好文 > 详细

C#串口通信->自动获取串口号

时间:2014-09-15 14:07:58      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   ar   for   2014   div   

 

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.IO.Ports;
 6 
 7 namespace SerialPortExample1
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             // Get a list of serial port names.
14             string[] ports = SerialPort.GetPortNames();
15 
16             Console.WriteLine("The following serial ports were found:");
17 
18             // Display each port name to the console.
19             foreach (string port in ports)
20             {
21                 Console.WriteLine(port);
22             }
23 
24             Console.ReadLine();
25 
26         }
27     }
28 }

bubuko.com,布布扣

---恢复内容结束---

C#串口通信->自动获取串口号

标签:style   blog   http   color   io   ar   for   2014   div   

原文地址:http://www.cnblogs.com/dingwei/p/3972605.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!