[英]Getting list of ports when using serial communication C#
我知道用于获取端口名称的语法
string[] ports = SerialPort.GetPortNames();
输出不完全符合预期。 当我继续打印字符串时,输出为:
System.String[]
我可能错过了一些东西。 请帮助...
您正在打印数组对象而不是数组中的字符串:
for(int i=0; i<ports.Length; i++)
{
Console.WriteLine(ports[i]);
}
或使用:
foreach(String port in ports)
{
Console.WriteLine(port);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.