namespace ClassLib
{
public class ClassBase
{
//无参数的构造函数
public ClassBase(){
}
public string property { set; get; }
//带参数的构造函数
public ClassBase(string a){
this.property = a;
}
}
}
namespace ClassLib
{
public class ClassChild:ClassBase
{
//调用其父类构造函数
public ClassChild()
: base(){
}
//调用其父类带参数的构造函数
public ClassChild(string b)
: base(b){
}
}
}
namespace ClassLib
{
public class ClassThis
{
//this用法,this指当前实例对象的指针 this = new Object();Object为任意对象
private string getList(string str)
{
return string.Format("字符:{0}", str);
}
public string getString(string str)
{
return this.getList(str); //等同于new ClassThis.getList(str);
}
public string thisParent { get; set; }
//定义构造函数
public ClassThis(){
this.thisParent= "thisParent";
}
public string thisChild { get; set; }
//调用自己的构造函数
public ClassThis(string child)
: this(){
thisChild = child;
}
}
}