以下是用C#写的串口助手。该程序使用了Windows Forms和System.IO.Ports命名空间。
using System;
using System.IO.Ports;
using System.Windows.Forms;
namespace SerialAssistant {
public partial class MainForm : Form {
private SerialPort serialPort;
public MainForm() {
InitializeComponent();
serialPort = new SerialPort();
}
private void MainForm_Load(object sender, EventArgs e) {
baudRateComboBox.Items.AddRange(new object[] { "9600", "19200", "38400", "57600", "115200" });
parityComboBox.Items.AddRange(Enum.GetNames(typeof(Parity)));
dataBitsComboBox.Items.AddRange(new object[] { "5", "6", "7", "8" });
stopBitsComboBox.Items.AddRange(Enum.GetNames(typeof(StopBits)));
portNameComboBox.Items.AddRange(SerialPort.GetPortNames());
if (portNameComboBox.Items.Count > 0) {