
关于C#程序开发的代码,看不懂,请高手帮忙分析下!谢谢 代码如下:
publicclassLion{privatestringname;privateintage;publicLion():this("unknown",0){Consol...
public class Lion{
private string name;
private int age;
public Lion():this ("unknown",0){
Console.WriteLine("Default {0}",name);
}
public Lion(string theName,int theAge){
name=theName;
age=theAge;
Console.WriteLine("Specified:{0}",name);
}
} 展开
private string name;
private int age;
public Lion():this ("unknown",0){
Console.WriteLine("Default {0}",name);
}
public Lion(string theName,int theAge){
name=theName;
age=theAge;
Console.WriteLine("Specified:{0}",name);
}
} 展开
1个回答
展开全部
就是新建一个类Lion 对其初始化时如果参数是 ("unknown",0) 则输出"Default {unknown} 如果参数是(string theName,int theAge) 则输出Specified:{thename} thename是输入的参数
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询