雨水回收工程:看一下c#的例子

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/20 12:38:04
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);
}