摩斯电码我爱你怎么敲:看一下c#的例子

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 09:59:29
using System;
interface s{
void t(int x){}
}
class f:s{
public void t(int x){}
}
class test
{
static void Main(){}
}

这个程序有什么不对,
error CS0531: 's.t(int)': interface members cannot have a definition

错误提示不是很清楚吗:error CS0531: 's.t(int)': interface members cannot have a definition
定义接口时不能定义成员,只能声明原型
interface s{
void t(int x){} //{}已是一个具体的程序段,只不过什么也不做而已
}
应改为
interface s{
void t(int x);
}