C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
iOS
Java
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
4
Reply
What is mean by virtual override ??
sathish
15y
6.8k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
Hi
virtual
And
override
both are keyword and
virtual
is use to declare
virtual method
in
base class
and when we implement the virtual method in the
derived method
we have to use the
override
modifier in method declaration
laxmikant Mishra
15y
0
I agree with Dushyant Sikligar that there is nothing called virtual override in C# as we need to explicitly define a "virtual" keyword in any of the methods we declare. If we want to override the MyMethod() in MyDerivedClass then we need to define it "virtual", otherwise it will throw complile time error.
Biprojit Roy Choudhury
15y
0
In C#.net, overriding is the basic feature of Inheritance, by default any method is non virtual. That means if any method is not declared as virtual then overriding will not possible (of course shadowing will be possible, either explicity shadowing or silent shadowing).
If One method is declared as virtual, then the overriden method of that virtual method will also by default virtual. This type of overriding is called virtual override.
for example
public class MyBaseClass
{
public virtual void MyMethod()
{
}
}
public class MyDerivedClass : MyBaseClass
{
public override void MyMethod()
{
base.MyMethod();
}
}
public class MySecondDerivedClass : MyDerivedClass
{
public override void MyMethod() //Howerver this method is not declared as virtual in MyDerivedClass
{
base.MyMethod();
}
}
Shovit Kumar
15y
0
In java, the default for methods is override. In c# that is not the case.
This talks about two classes, the base class and the overriding class. What
happens when you have a third class in the mix, extending the second class,
how can you indicate the method in the third class is overridding the
overridden method? Do you declare the second method to be virtual override?
ClassA
-------------
virtual DrawWindow(){//code}
^
|
|
ClassB
---------
override DrawWindow(){//code}
What happens if you want to creat a ClassC which extends ClassB, and you
want to override DrawWindow()? How do you declare the ClassB.DrawWindow
method?
Dushyant Sikligar
15y
0
Can an assembly have EXE?
At what movement we would go for server-side validation and Client-side validation ?
Message