private string GetComNumberstring serialPortName)
{
string comNum = "";
int start = serialPortName.IndexOf("(") + 1;
int end = serialPortName.IndexOf(")") - 1;
comNum = serialPortName.Substring(start, end - start +1);
return comNum;
}
传入"USB-SERIAL CH340 (COM3)",得到"COM3"