当前位置:编程学习 > C#/ASP.NET >>

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));

}
}
}

 

 

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,