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

About Virtual functions and their use ?

Answer Posted / deepak jindal

If a base class method is to be overriden, It is defined
using virtual keyword. You need to use the override keyword
in order to re-implement the virtual method. Exp:

public class Employee
{
public virtual void SetBasic(float money) //This method may
be overriden
{ Basic += money; }
}


public class Manager : Employee
{
public override void SetBasic(float money) //This method is
being overriden
{
float managerIncentive = 10000;
base.SetSalary(money + managerIncentive); //Calling base
class method
}
}

Is This Answer Correct ?    14 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a generic in c#?

865


what is the scope of anonymous type ?

940


What is better C# or VB.NET?

871


What is the output of TextWriterTraceListener redirected?

994


What is an assembly qualified name? Is it a filename? How is it different?

879


What is the benefit of dependency injection c#?

853


Whats an assembly? Describe the importance of assembly?

853


What is using keyword?

866


What is a property in c#?

852


Why abstract class is not instantiated in c#?

891


Can you pass value types by reference to a method?

898


Can you put two constructor with the same structure in a class?

860


What is COM Interoperability?

909


Explain publishers and subscribers in events.

892


Does a class need a constructor c#?

855