会c#的麻烦进来帮下忙using System;using System.Collections.Generic;using System.Text;namespace 类{class Dog{/* static void Main(){Dog Haba = new Dog();Haba.eat();Haba.sound();}*/public void eat(){Console.WriteLine("吃啊!");}public void sou
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/18 03:18:26
会c#的麻烦进来帮下忙using System;using System.Collections.Generic;using System.Text;namespace 类{class Dog{/* static void Main(){Dog Haba = new Dog();Haba.eat();Haba.sound();}*/public void eat(){Console.WriteLine("吃啊!");}public void sou
会c#的麻烦进来帮下忙
using System;
using System.Collections.Generic;
using System.Text;
namespace 类
{
class Dog
{
/* static void Main()
{
Dog Haba = new Dog();
Haba.eat();
Haba.sound();
}*/
public void eat()
{
Console.WriteLine("吃啊!");
}
public void sound()
{
Console.WriteLine("叫啊!");
}
}
class Car
{
static void Main()
{
Car benz = new Car();
Dog Haba = new Dog();
benz.run();
Haba.eat();
Haba.sound();
}
void run()
{
Console.WriteLine("好快!");
}
public Car()
{
Console.WriteLine("ABC!");
}
}
}
我是初学者,我想问问 public car(){} 为什么“ABC!”会在最上面出来而不是最下面?
会c#的麻烦进来帮下忙using System;using System.Collections.Generic;using System.Text;namespace 类{class Dog{/* static void Main(){Dog Haba = new Dog();Haba.eat();Haba.sound();}*/public void eat(){Console.WriteLine("吃啊!");}public void sou
public car(){}是car这个类得构造函数,执行时首先执行入口函数 static void Main(),第一句Car benz = new Car();
当你new出一个car的实体对象的时候 就会走他的构造函数,所以他会出现在最上面