What does the keyword virtual mean in the method definition?
Answers were Sorted based on User's Feedback
Even though the function in base class is declared with
virtual keyword, it is not compulsory that the derived
class must override it.
namespace TestNewOverride
{
class MyBaseClass
{
int a;
public virtual int doubleit()
{
return 2 * a;
}
public MyBaseClass()
{
a = 5;
}
}
class MyDerivedClass:MyBaseClass
{
public static void Main()
{
}
}
}
| Is This Answer Correct ? | 7 Yes | 0 No |
Answer / praseetha sandeep
when you have a method defined in a class which you want
to allow to be implimented by inherited class you can use
virtual function
| Is This Answer Correct ? | 4 Yes | 0 No |
What is lazy in c#?
What?s the difference between the System.Array.CopyTo() and System.Array.Clone()?
Can I call a virtual method from a constructor/destructor?
What is the process of delegation?
What are expressions c#?
What are partial classes and use of partial classes?
what are the events in delegate?
What exception can an overridden method throw in comparison with the method it is overriding?
How garbage collection deals with circular references.
How does insertion sort work?
What?s the advantage of using System.Text.StringBuilder over System.String?
How do I enforce const correctness in c#?
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)