本文介绍了在C#编码中了解com端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该如何在c#中编写代码以查找com端口((并自动将其更改为com1))
how can i write a code in c# for finding com port ((and automatically change it to com1))
推荐答案
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();
}
}
}
这篇关于在C#编码中了解com端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!