If I want to override a method 1 of class A and in class b
then how do you declare ?
Answers were Sorted based on User's Feedback
Answer / sridevi
declare method1 as virtual in classA and then create classB
as derived class of ClassA and override method1 in classB.
class ClassA{
public virtual add();
}
class ClassB:ClassA{
public overrride add(){
console.WriteLine("Im in derived");
}
}
| Is This Answer Correct ? | 10 Yes | 0 No |
Answer / ch.venu
Ans:
we can override the parent class method under its child
class only when the parent class declared the method as
virtual
ex:
class Parent
{
public virtual void Test()
}
now thar virtual method of the parent class can be override
the child class using override modifier
ex:
class child:Parent
{
public override void Test()
{
Console.WriteLine("hi this is derived class") ;
}
}
but it is only optional for the child classs to override the
virtual method of its parent class
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ashwini c havan
we can override the parent class method under its child
class only when the parent class declared the method as
virtual and abstract..............
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / avaneesh bajoria
If using VB.NET as the code behind, you use must override
instead of virtual and overrides in the derived classs
public class parent
public mustoverride sub walk()
messagebox.show("Parent")
end sub
end class
public class child
inherits parend
public overrides sub walk()
messagebox.show("Child")
end sub
end class
| Is This Answer Correct ? | 0 Yes | 1 No |
How to store image file in Sql server database?
4 Answers Unique Software Systems,
What are the differences between events and delegates in c#?
Why do I get a security exception when I try to run my c# app?
What is final keyword in c#?
When a switch is said to be congested?
Can you override private virtual methods?
Why do we need oops in c#?
What are bitwise logical operators?
What is exe file in c#?
What is the main purpose of xml?
Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
What are the namespace level elements?
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)