How can you overload a method?

Answer Posted / rakesh

A class contains more than one function with the same name
but different method signature ie different access
type,return type,parameters.

public void int sum(int i,int j)
{
int tot=i+j;
Console.WriteLine(tot);
}

public void double sum(double p,double q)
{
double tot=p+q;
Console.WriteLine(tot);
}

if we are passing integer values means the first function
will invoke,and if we are passing double values means the
second will work.This is method overloading.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is polymorphism and its types in c#?

675


What is the extension of c# file?

681


Is there throws keyword in c#?

696


What is concrete method in c#?

721


Is it true that all c# types derive from a common base class?

786


1. Describe page life cycle?

1857


Why do we use constructors in c#?

834


Define multicast delegate in c#?

727


What will a loop recorder show?

767


Why are c# strings immutable?

748


Can we have two main methods in c#?

752


What is wcf c#?

751


What are logical operators in c#?

745


How to sort an int array in c#?

755


What are the various components in crystal reports?

746