private void btnSave_Click(object sender, EventArgs e) { string port = this.txtPort.Text.Trim(); try { int tmp = Convert.ToInt32(port); ClientConfig config = new ClientConfig(); config.Port = tmp; config.Ip = this.txtIp.Text.Trim(); config.ServerIp = this.txtServerIp.Text.Trim(); ClientConfig.SaveConfig(config); MessageBoxHelper.Show("保存成功"); } catch (Exception ex) { MessageBoxHelper.Show("端口必须是数字!"); } }