Edit

Share via


Compiler Error CS0508

'Type 1': return type must be 'Type 2' to match overridden member 'Member Name'

An attempt was made to change the return type in a method override. To resolve this error, make sure both methods declare the same return type.

Example

The following sample generates CS0508.

// CS0508.cs  
// compile with: /target:library  
abstract public class Clx  
{  
   public int i = 0;  
   // Return type is int.  
   abstract public int F();  
}  
  
public class Cly : Clx  
{  
   public override double F()  
   {  
      return 0.0;   // CS0508  
   }  
}