C#的简单题目

来源:百度知道 编辑:UC知道 时间:2024/06/19 22:57:51
using System;
using System.Collections.Generic;
using System.Text;

class Vehicle
{
public int wheels;
protected float weight;
public Vehicle(int w, float g)
{
wheels = w;
weight = g;
}
public void show()
{
Console.WriteLine("The wheel of the vehicle is {0}", wheels);
Console.WriteLine("The weight of the vehicle is {0}", weight);
}
}

class Train
{
public int num;
private int passengers;
private float weight;
public Train() { ;}
public Train(int n, int p, float w)
{
num = 0;
passengers = p;
weight = w;
}
public void show()
{
Console.WriteLine("The

他们都已经说到了···总之先把public void Main()改成static void Main(string[] args)
另外也有人提到了,您是手打的这些????而且这个是完整的源码?

那就有另外一个问题了
命名空间呢?我似乎没看见你这程序自己的命名空间啊····

using System;
using System.Collections.Generic;
using System.Text;

class Vehicle
{
public int wheels;
protected float weight;
public Vehicle(int w, float g)
{
wheels = w;
weight = g;
}
public void show()
{
Console.WriteLine("The wheel of the vehicle is {0}", wheels);
Console.WriteLine("The weight of the vehicle is {0}", weight);
}
}

class Train
{
public int num;
private int passengers;
private float weight;
public Train() { ;}
public Train(int n, int p, float w)
{
num = 0;
passengers = p;
weight = w;
}
public void show()