Interviews - C# Corner

Atulya Panda
Is it possible to override private virtual methods?
By Atulya Panda in C# on Nov 26 2012
  • raj kadam
    Feb, 2015 23

    no,you can not override the private virtual method bcoz virtual method cannot be private!!!

    • 2
  • Dhananjay Salunke
    Nov, 2015 2

    CLR doesn't allow to write private virtual method, so its not possible at all.

    • 1
  • Dhananjay Salunke
    Nov, 2015 2

    CLR doesn't allow to write private virtual method, so its not possible at all.

    • 1
  • Anupam Singh
    May, 2014 13

    Hi Atulya, Private virtual methods cannot be declared in the C# language. So no question comes to override i think.Seems interviewer was tweaking you :).

    • 1
  • Neeraj Negi
    May, 2014 1

    as it is not possible to inherit private methods from parent class you cant override it.

    • 1
  • Dhananjay Salunke
    Nov, 2015 2

    CLR doesn't allow to write private virtual method, so its not possible at all.

    • 0
  • Mitesh Patel
    Aug, 2015 9

    there is not allow to write virtual method as private so there is no question for override private virtual method

    • 0
  • Ashvani chaudhary
    Jul, 2015 3

    Hello Atulya As we know that the virtual method is designed to use in derived class by override concept in c# . We can declare virtual method private but at the compile time it through error (Virtual method cant be private). Even C# basic concept is private member cant be accessed outside the call regardless of by property. So finally its clear we cant declare virtual method as private and cant override it in derived class

    • 0
  • Prasenjit  Dey
    Aug, 2013 5

    No. It cannot inherited from other class due to private keyword

    • 0
  • JAGAN reddy
    Apr, 2013 21

    no u cant

    • 0
  • keerthi rakasi
    Feb, 2013 28

    No.And also the default access specifier in abstract methods is public.

    • 0
  • Nehal Thakkar
    Dec, 2012 2

    No

    • 0
  • Nehal Thakkar
    Dec, 2012 2

    No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.

    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS