C#接口疑问

来源:百度知道 编辑:UC知道 时间:2024/06/02 01:11:44
请教给为老师,在看接口时写了这个代码,为什么
public Example()
{
; //加“;”就出错 ,将“;”删除就对了
}
源代码如下:
interface IsExampleA
{
void PrintA();
}
interface IsExampleB
{
void PrintB();
}
class Example:IsExampleA ,IsExampleB
{
public Example()
{

}

public void PrintA()
{
Console.WriteLine("it's the first interface");
}

public void PrintB()
{
Console.WriteLine("it's the second interface");
}
}
class Test
{
static void Main()
{
Example ex = new Example();
ex.PrintA();
ex.PrintB();
Console.ReadKey();
}
}
谢谢各位老师了!!

确实很无语,,,

其实加上 分号 没有错
编译器 只是把分号认为是一个语句的结尾,所以加一个分号 只是一个空语句而已,没有错

但是你是加入的 中文输入法下面的 分号‘;' 而不是英文的';'

很无语 你为什么要加它