No suitable method found to override

    General discussion

  • Hi ,

    I have a class instrument which have a interface MarketData.

    namespace CS.AM.FixedIncome.YieldCurve


    interface MarketData


    void GetMarketData();


    public class Instrument



    I am implemting this in class instrument1

    class instrument1: MarketData


    Instrument instrument = new Instrument();

    public override void GetMarketData()




    I am getting here error No suitable method found to override.

    Wednesday, June 04, 2008 10:24 AM

All replies

  • Hi,

    In order to implement a method of an Interface, all you have to do is give it the same name. There is no base implementation in an interface, so there is no base implementation to override. When deriving from an (abstract) class that does have implementation, the override keyword comes into play.

    In your case, this would be...

    1 class instrument1: MarketData  
    2 {  
    3     Instrument instrument = new Instrument();  
    5     public void GetMarketData()  
    6     {  
    7     }  

    Hope this helps

    Mark the best replies as answers - my blog:
    Wednesday, June 04, 2008 10:35 AM