Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0738

Visual Studio 2008

'type name' does not implement interface member 'member name'. 'method name' cannot implement 'interface member' because it does not have the matching return type of ' type name'.

The return value of an implementing method in a class must match the return value of the interface member that it implements.

To correct this error

  • Change the return type of the method to match that of the interface member.

The following code generates CS0738 because the class method returns void and the interface member of the same name returns int:

using System;

interface ITest
    int TestMethod();
public class Test: ITest
    public void TestMethod() { } // CS0738
    // Try the following line instead.
    // public int TestMethod();

Community Additions

© 2014 Microsoft