How can you overload a method?

Answers were Sorted based on User's Feedback



How can you overload a method?..

Answer / 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

How can you overload a method?..

Answer / swapna

we can overload a method by giving same method names with
different parameters. Parameters may differ in data type or
in number.
This is called method overloading .

Is This Answer Correct ?    1 Yes 0 No

How can you overload a method?..

Answer / niraj bajaj

Hi

@Rakesh

Return types doesnt include in these..
only different set of parameters and their access types..

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Is string nullable in c#?

0 Answers  


What is the main method?

0 Answers  


What is the difference between dictionary and hashtable in c#?

0 Answers  


How much time will it take to learn unity?

0 Answers  


What is the relation between classes and objects?

0 Answers  






Does c# support a variable number of arguments?

0 Answers  


What is data adapter in c#?

0 Answers  


What is the solution if you need to manipulate sets of items?

0 Answers  


Does c# have a 'throws' clause?

0 Answers  


How can I get the ascii code for a character in c#?

0 Answers  


what is the fastest way to concatenate strings in c sharp?

4 Answers   HCL,


What is virtual class in C#?

0 Answers   B-Ways TecnoSoft,


Categories