Can you override private virtual methods?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you determine whether a string represents a numeric value?

516


What is event and delegates in c#?

572


Is char * null terminated?

520


What is difference between an Structure and Class?

563


write program in c# using this instructions name avinash varma ,work experiance<2,nochildren his work experiance is higher than 5 years,more than one children one children name is diwakar,number of years of work eperiance at current company is the ratio of children and work experiance is 0.21 to 0.5

1870






3. Use layered architecture for coding. s.no name description 1 abc xxxxxxxxx 2 abc xxxxxxxxx 3 4 5 6 7 8 Select all Clear all Add Delete Name Description Save close

1451


What is a property in c#?

472


What is using in c#?

465


What is activator c#?

477


What are the access modifiers in c#?

497


What are native methods?

482


Is c# difficult to learn?

480


What is class sortedlist underneath?

566


What is a bool in c#?

471


Define c# i/o classes?

527