Can you override private virtual methods?
Answers were Sorted based on User's Feedback
Answer / umesh
No, moreover, you cannot access private methods in
inherited classes, have to be protected in the base class to
allow any sort of access.
Is This Answer Correct ? | 28 Yes | 6 No |
Answer / payal mehta
WE can not use private access modifier for VIRTUAL,INTERFACE
and also we can not inherit private methods or properties
in inherited classes.
Is This Answer Correct ? | 14 Yes | 2 No |
Answer / asim bukhari
we cant use private access modifier for VIRTUAL, INTERFACE
and ABSTRACT
Is This Answer Correct ? | 7 Yes | 2 No |
Answer / vivek
virtual or abstract members cannot be private.
Ex: error occurs during the static compilation phase, which
means that no program that declares a private virtual method
will ever be executed in any way.
C#
class A
{
private virtual int Test()
{
return 1;
}
}
class Program
{
static void Main()
{
}
}
Compile-time error
Error 1
'A.Test()': virtual or abstract members cannot be private
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / kirti
No. Private methods are not accessible outside the class.
Is This Answer Correct ? | 0 Yes | 0 No |
Define multicast delegate in c#?
How to call a function when a class implements 2 interfaces and function is present in both interfaces?
Is it possible to have different access modifiers on the get/set methods of a property?
What is a event in c#?
Why do we need escape characters?
hi, I am a begineer to c sharp. I have written a code for finding out prime numbers. Can anyone identify what are the flaws in my code. Kindly donot complex the code or present logic because i am new to c sharp and just started learning programming language.Thanks in advance. class Program { static void Main(string[] args) { int a,b=1; a = int.Parse(Console.ReadLine()); c= int.Parse(Console.ReadLine()); if (a % b == 0 && a % 2 != 0 && a % a == 0) Console.WriteLine(a); else if (a % b == 0 && a % 2 == 0) Console.WriteLine(a%2); Console.WriteLine("Number is not PRIME"); Console.ReadLine(); } } }
How to handle exceptions that are raised in a component?
What are the 3 elements of delegation?
Why is static constructor called first?
Can we create multiple constructors?
Can constructor have return type c#?
Is dictionary reference type c#?