我在C#和此網站中相對較新。我目前正在嘗試使該應用程序存儲員工的數據(例如姓名,姓氏,身份證號,薪水),并根據命令顯示所選員工的數據。我的問題是,每次單擊“保存按鈕”以創建該類的新實例時,我都不知道要創建哪種類以及如何構建它以及如何調用它,因此將保存從中獲取的數據表單的文本框。我在論壇中進行搜索,并設法將其寫在表單中:private void button1_Click(object sender, EventArgs e) { Employee newemployee = new Employee(); { string fname = textBox1.Text; string sname = textBox2.Text; string id = textBox3.Text; string sal = textBox4.Text; label5.Text = fname; label6.Text = sname; label7.Text = id; label8.Text = sal; }}而這在類里面:public class Employee { public string fname { get; set; } public string sname { get; set; } public string id { get; set; } public string sal { get; set; }}但是,結果是,該類根本沒有使用(顯然是因為它沒有完成),并且標簽是直接通過文本框打印的。
- 3 回答
- 0 關注
- 220 瀏覽
添加回答
舉報
0/150
提交
取消