public Employee(string name,string alias){// Use this to qualify the fields,name and alias:this.name = name;this.alias = alias;}this的用法this.name=name 具体点我有点狠难理解

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/28 16:48:34
public Employee(string name,string alias){// Use this to qualify the fields,name and alias:this.name = name;this.alias = alias;}this的用法this.name=name 具体点我有点狠难理解

public Employee(string name,string alias){// Use this to qualify the fields,name and alias:this.name = name;this.alias = alias;}this的用法this.name=name 具体点我有点狠难理解
public Employee(string name,string alias)
{
// Use this to qualify the fields,name and alias:
this.name = name;
this.alias = alias;
}
this的用法this.name=name 具体点我有点狠难理解

public Employee(string name,string alias){// Use this to qualify the fields,name and alias:this.name = name;this.alias = alias;}this的用法this.name=name 具体点我有点狠难理解
这是个构造函数,this.name指当前类的属性,后一个name是构造函数中的参数
这就是给类中的属性赋值
这样写就清楚了
public Employee(string strName,string strAlias)
{
// Use this to qualify the fields,name and alias:
this.name = strName;
this.alias = strAlias;
}