C#中简单的this与get的用法(string,decimal)
代码
namespace First
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Employee E1 = new Employee("xiaohong","you");
E1.Salary =4.2m;
E1.printEmployee();
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hi");
this.Close();
}
}
class Employee
{
private string name;
private string alias;
private decimal salary;
public Employee(string name, string alias)
{
this.name = name;
this.alias = alias;
}
public decimal Salary
{
get
{
return salary;
}
set
{
salary = value;
}
}
public void printEmployee()
{
MessageBox.Show("Name:" + name +" "+ "Alias:" + alias +" "+ "num:" + salary);
// MessageBox.Show( Employee.SalcTax(this));
}
}
}
代码
namespace First
{
public partial class补充:软件开发 , C# ,
上一个:C#做托盘程序
下一个:C#用panel实现子窗体的切换
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,
部分文章来自网络,