Hi
using system.io.ports
string[] ports = SerialPort.GetPortNames();
var sortedList = ports.OrderBy(port => Convert.ToInt32(port.Replace("COM", string.Empty)));
foreach(string port in ports)
{
DrpPort.Items.Add(port);
DrpPort.DataBind();
}
It is not displaying anything in Drop-Down , it is not going in loop.
Thanks
List of Com Ports
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sam HobbsRank #107 · 20.5K reputationPosted Oct 4, 2011, 9:40 AM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 4, 2011, 12:19 AM EDT
I'd print out the value of ports.Length to see whether it's greater than zero.
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 4, 2011, 11:52 AM EDT
Please do not forget to mark "Accepted Answer".