在接口中添加方法????我调不出来。。

using System;
interface IVehicle
{
public void start(int x);
public void stop(int x);
}
class Bike : IVehicle { }
class Bus : IVehicle { }
class interfaceDemo
{
public static void main()
{
Bike b1 = new Bike();
Bus b2 = new Bus();

}

}

''''using System;
interface IVehicle
{
void start(int x);
void stop(int x);
}

class Bike : IVehicle {
public void start(int x)
{
//...
}
public void stop(int x)
{
//...
}
}
class Bus : IVehicle {
public void start(int x)
{
//...
}
public void stop(int x)
{
//...
}
}

class interfaceDemo
{
public static void main()
{
Bike b1 = new Bike();
Bus b2 = new Bus();

 using System;
 interface IVehicle
 {
void start(int x);
void stop(int x);
 }

class Bike : IVehicle {
public void start(int x)
{
    //...
}
public void stop(int x)
{
  //...
}
}
 class Bus : IVehicle { 
 public void start(int x)
{
    //...
}
public void stop(int x)
{
  //...
}
 }

 class interfaceDemo
 {
 public static void main()
 {
 Bike b1 = new Bike();
 Bus b2 = new Bus();
}
}
'
'''

sorry 这个编辑器用的不习惯。

'using System;
 interface IVehicle
 {
 void start(int x);
 void stop(int x);
 }

class Bike : IVehicle {
 public void start(int x)
 {
 //...
 }
 public void stop(int x)
 {
 //...
 }
 }
 class Bus : IVehicle { 
 public void start(int x)
 {
 //...
 }
 public void stop(int x)
 {
 //...
 }
 }

class interfaceDemo
 {
 public static void main()
 {
 Bike b1 = new Bike();
 Bus b2 = new Bus();
}
}

希望这次对了

using System;
 interface IVehicle
 {
 void start(int x);
 void stop(int x);
 }

class Bike : IVehicle {
 public void start(int x)
 {
 //...
 }
 public void stop(int x)
 {
 //...
 }
 }
 class Bus : IVehicle { 
 public void start(int x)
 {
 //...
 }
 public void stop(int x)
 {
 //...
 }
 }

class interfaceDemo
 {
 public static void main()
 {
 Bike b1 = new Bike();
 Bus b2 = new Bus();
}
} 
     interface IVehicle
    {
        void start(int x);
        void stop(int x);
    }
    class Bike : IVehicle
    {
        public void start(int x) { Console.WriteLine(x); }
        public void stop(int x) { Console.WriteLine(x); }
    }
    class Bus : IVehicle
    {
        public void start(int x) { Console.WriteLine(x); }
        public void stop(int x) { Console.WriteLine(x); }
    }
    class interfaceDemo
    {
        public static void main()
        {
            Bike b1 = new Bike();
            Bus b2 = new Bus();

        }

    }

接口定义不能加public,private修饰符,继承接口的类要实现接口的方法

你的错误主要是两个

一个是,如果你的类实现了接口,必须定义接口定义的方法,并且方法名参数返回值要一样。(不考虑协变逆变,这个暂时你学不到)

一个是,你的接口定义方法不要public修饰了。