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...

Can we have the method in drived class with the same name
which is there in base class?

Answer Posted / brijender p rana

It is possible to hide the base class method with the
derived class without using Virtual in base class and
Override keyword in subclass.there are some condition where
we have to redefine any method in derived class same name
in base class now question arise how can we hide the method
anwer is simple and logical we use the modifier NEW which
tell the compiler that derived class method "hides the base
class method. There are some example:
Class baseclass
{
Public void display()
{
console.writeline("base method");
}
}
class derived : baseclass
{
public new void display()
{
console.writeline("dervied mthod");
}
}
class test
{
public static void main()
{
derived d=new derivedclass();
d.display();
}
}

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use?

1044


What do you mean by stack and heap in c#?

912


Define acid rule of thumb for transactions in c#.

891


Can fields inside a class be virtual?

959


What are the fundamental differences between value types and reference types?

1061


What is the difference between overriding and overloading in systemverilog?

971


What is sealed class in c#?

886


How to prevent the error while updating ui control from another thread?

960


List some of the basic string operation?

903


What is parsing?

916


What is console write in c#?

922


What is the main purpose of xml?

924


If the interface in c# only contains the declaration of the methods and we need to define those methods in the class, then why we use the interface?

1004


How do you create user defined data types in c#?

999


What is function c#?

895