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 you overload a method of class A in Class B if it is
derived class of A?If it is yes tell me how is it possible?

Answer Posted / lalit pradhan

namespace Test
{
class Program
{
static void Main(string[] args)
{
A a = new A();
a.Method();

B b = new B();
b.Method("From B");

Console.ReadKey();
}
}

class A
{
public void Method()
{
Console.WriteLine("From A");
}
}

class B : A
{
public void Method(string s)
{
Console.WriteLine(s);
}
}
}

Is This Answer Correct ?    15 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which are the loop types available in c#?

892


what class is underneath the sortedlist class?

894


What is namespace in oop?

875


What is a function c#?

906


Can you have an array of arrays?

919


What does mean before a string in c#?

940


Is type nullable c#?

880


What is overriding in c#?

835


Is stringbuilder faster than string concatenation c#?

865


What is get set in c#?

914


Explain about Error handling and how this is done

894


How long can a string be c#?

846


Are private members inherited in c#?

917


What is data hiding in c#?

852


What is xml comments in c#?

835