Expand Minimize
0 out of 2 rated this helpful - Rate this topic

Compiler Error CS0508 

Error Message

'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
   }
}
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.