HomeCSharpC# Error CS1715 – ‘{0}’: type must be ‘{2}’ to match overridden member ‘{1}’

C# Error CS1715 – ‘{0}’: type must be ‘{2}’ to match overridden member ‘{1}’

C# Error

CS1715 – ‘{0}’: type must be ‘{2}’ to match overridden member ‘{1}’

Reason for the Error & Solution

‘Type1’: type must be ‘Type2’ to match overridden member ‘MemberName’

This error is the same as , except that CS0508 now only applies to methods that have return types, while CS1715 applies to properties and indexers that only have ‘types’ instead of ‘return types’.

Example

The following code generates CS1715.

// CS1715.cs  
abstract public class Base  
{  
    abstract public int myProperty  
    {  
        get;  
        set;  
    }  
}  
  
public class Derived : Base  
{  
    int myField;  
    public override double myProperty  // CS1715  
    // try the following line instead  
    // public override int myProperty  
    {  
        get { return myField; }  
        set { myField;= value; }  
    }  
  
    public static void Main()  
    {  
        Derived d = new Derived();  
        d.myProperty = 5;  
    }  
}  

Leave a Reply

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...