10. Overloding and overriding.

Answer Posted / preetham

Overloading :

If you want to use same method in a different ways by using different method signatures.It should be in the same class.
In the below example there is no parameter passed in first time calling but same method we used with passing multiple parameters. This is what overloading means.
Ex: public void FirstMethod(){}
public void FirstMethod(int i, string s){}

Overriding :

It deals with two methods one in a parent class and one in a child class that have the same signature.
The method in parent class should be declared as virtual and the method in the derived class should be declared as override in their method signature. Every virtual method in the parent class should be override in the derived class.
Ex : public virtual void FirstMethod(){}
public override void FirstMethod(){}

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

.Net Frame work arch?

1789


How do we do authentications using atlas?

711


what is diffrent beatween localprinter and networkprinter

1534


Explain .net mobile selectionlist control? : Microsoft dot net mobile

707


What are the main Tools to develop .Net Application?

691


How can I write my own .NET host?

752


Explain domestic architecture artifacts? : .NET Architecture

700


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

691


Define a managed code? : Dot net architecture

677


How to prevent my .NET DLL to be decompiled?

768


How cache is used? : Dot net architecture

678


What is the purpose of cache? How is it used? : Dot net architecture

673


Explain domestic architecture artifacts? : Dot net architecture

689


Difference between throw exception and rethrowing ?

1842


Can I create my own metadata attributes?

719