创建 Car
的构造函数,并调用它:
class Car
{
public string model;
@(6) @(5)
{
model = "Mustang";
}
static void Main(string[] args)
{
@(3) Ford = @(3) @(6)
Console.WriteLine(Ford.model);
}
}
class Car
{
public string model;
public Car()
{
model = "Mustang";
}
static void Main(string[] args)
{
Car Ford = new Car();
Console.WriteLine(Ford.model);
}
}