我目前正在学习关于类构造函数的在线课程。它给出的错误名称“名称”在当前上下文中不存在。
class Forest
{
// first constructor
public Forest(string biome, string name)
{
this.Name = name;
this.Biome = biome;
Age = 0;
}
//second constructor
public Forest(string biome) : this(name, "Unknown")
{
Console.WriteLine("Name property not specified. Value defaulted to 'Unknown'");
}
}