14
Reply

Suppose, We have class A and class B having same method. class B inheriting from A. class A not defined virtual that method but Class B define override, then what will happen?

Ravi Kumar

Ravi Kumar

Jan 07, 2016
3.6k
2

    Program will not compile generate error like; Error: Class B cannot override inherited member 'Class A' because it is not marked virtual, abstract, or override.

    Ravi Kumar
    January 07, 2016
    8

    You can only override the virtual methods.

    Prakash Tripathi
    April 11, 2016
    3

    It will give a compilation error. Error : 'ClassB.Function()': cannot override inherited member 'ClassA.Function()' because it is not marked virtual, abstract, or override

    Sweta Shetye
    December 04, 2016
    2

    Method of class A is hidden now and method of class B is invoked when called.

    Vishal Jadav
    August 08, 2016
    2

    No Suitable method found to override

    it will give compilation error...

    Rahul Sharma
    October 18, 2016
    1

    I think you must be create virtual method in Class A than you will be use override method in derived class with out it Compilation Error is occur.

    Nilesh Patel
    September 19, 2016
    1

    Error : cannot override inherited member ,because it is not marked virtual, abstract, or override.

    Puneet Kankar
    September 10, 2016
    1

    metod overiding

    Hiren Parmar
    August 14, 2016
    1

    In C# virtual is just optional...still it ovveride the method present in classB

    Prashant Singh
    March 19, 2016
    1

    here throw Exception, bcz, if base class have member method which does not marke as a virtual or abstract so compiler does not allow we go for in derived class a override that member method which is non virtual or non abstract.so if we want override those method then we have must go for that member method mark as a virtual or abstract. keep in mind.

    Dheeraj Kumar Jha
    March 14, 2016
    1

    an warning is shown

    Mukesh Kumar
    August 29, 2017
    0

    will throw the exception "cannot override inherited member bcoz it is not marked as virtual in a parent class

    Mohsin Mukri
    July 06, 2017
    0

    here throw Exception, bcz, if base class have member method which does not make as a virtual or abstract so compiler does not allow we go for in derived class a override that member method which is non virtual or non abstract. keep in mind.

    Dheeraj Kumar Jha
    March 14, 2016
    0