serial port - displaying empty results C# -
guys using following code displaying no output , not showing error. please help.
private void button1_click(object sender, eventargs e) { string[] ports = serialport.getportnames(); //display each port name console. foreach (string port in ports) { listbox1.items.add(port); //_serialport.open(); } }
using system; namespace listserial { class program { public static void main(string[] args) { string[] names = null; try { names = system.io.ports.serialport.getportnames(); } catch(exception ex) { console.writeline(ex.message); } if(names!=null) { int portnum = names.length; if (portnum != 0) { (int = 0; < names.length; i++) console.writeline(names[i]); } else { console.writeline("no_com"); } } } } }
Comments
Post a Comment