编译器错误 CS0738
更新:2007 年 11 月
错误消息
“type name”不实现接口成员“member name”。“method name”无法实现“interface member”,因为它没有匹配的返回类型“type name”。
类中的实现方法的返回值必须与该方法所实现的接口成员的返回值相匹配。
更正此错误
- 更改方法的返回类型,以便与接口成员的返回类型相匹配。
示例
下面的代码生成 CS0738,因为类方法返回 void,而同名的接口成员却返回 int:
using System;
interface ITest
{
int TestMethod();
}
public class Test: ITest
{
public void TestMethod() { } // CS0738
// Try the following line instead.
// public int TestMethod();
}