以添加学员信息的窗体应用举例:
//首先先封装数据,new一个学生类
//然后初始化对象 new() { }
private void button1_Click(object sender, EventArgs e)
{
//封装数据
Student objStudent = new Student()
//对象初始化器
{
Name = this.txtName.Text.Trim(),
Age = Convert.ToInt32(this.txtAge.Text.Trim()),
Gender = this.txtGender.Text.Trim(),
Birtheday = Convert.ToDateTime(this.txtBrithday.Text.Trim())
};
}
标签:Trim,Convert,封装,C#,Text,对象,Student,new From: https://www.cnblogs.com/tu1355140301/p/17399753.html