Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



If I want to override a method 1 of class A and in class b then how do you declare ?..

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

If I want to override a method 1 of class A and in class b then how do you declare ?..

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

If I want to override a method 1 of class A and in class b then how do you declare ?..

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

If I want to override a method 1 of class A and in class b then how do you declare ?..

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

Post New Answer

More C Sharp Interview Questions

Define method overloading in c#?

0 Answers  


Explain hash table in c# ?

0 Answers  


Is c# front end or back end?

0 Answers  


What is console write in c#?

0 Answers  


What is type safe code?

0 Answers  


What are collection classes?

0 Answers  


how to use msflexgrid in asp.net

1 Answers   nSoft, Unichem,


What is the correct way of declaring an xml namespace?

0 Answers  


if we inherit class in stack so object of stack will store in stack or heap? as class a { int s; public aa(){} } stack mystack:a { } mystack obj; ans: about obj

1 Answers  


What is the use of private constructor in c#?

0 Answers  


What is a namespace server?

0 Answers  


What are the types of threading models ?

4 Answers   Digital GlobalSoft,


Categories