Can you override private virtual methods?
Answers were Sorted based on User's Feedback
Answer / tsahi
You cannot write virtual private methods, let alone override
them. as noted above, a private virtual method will not compile.
| Is This Answer Correct ? | 8 Yes | 0 No |
Answer / dharmendra nonia
No,We can't override the private virtual method because
it private access specifier does not allow to inherit the
private member of a class in a derived class.
Ex:--
-------
using System;
public class ABC
{
private virtual void mm()
{
}
}
public class abc:ABC
{
private override void mm()
{
Console.WriteLine("Hello");
}
}
class d:abc
{
public static void Main()
{
d D=new d();
D.mm();
}
}
Output:-
--------
ae.cs(4,23): error CS0621: 'ABC.mm()' : virtual or abstract
members cannot be
private
ae.cs(11,24): error CS0621: 'abc.mm()' : virtual or
abstract members cannot be
private
| Is This Answer Correct ? | 6 Yes | 0 No |
Are c# objects passed by reference?
Define parsing? Explain how to parse a datetime string?
i have a question which is quite simple but yet complicated for me my question is why do we use void, if it does not return anything to the compiler? if it is used for normal display it can also be done by what is called Console.Write() or Consol.WriteLine() and if i do not use void with my method then my compiler throws me an error. if i return a value say integer then i write public int fun() display of the result can also be done here then why is it so necessary to use void with a function and why so compiler throw us an error if v don't use void return type?
What is thread in c#?
What is a hash table c#?
Explain About Postback
How to reverse each word in a string using c#?
What are desktop applications examples?
Can you prevent your class from being inherited and becoming a base class for some other classes?
4. Describe the process when we send a request URL? And who is responsible for that?
What is scaffolding in c#?
difference between keyword internal and protected?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)