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

Using system; class main { public static void Main() { int a = 1; for (int i = 0; i < 10; i++) { int j = a * 5; Console.WriteLine(a + "*5=" + j); a++; } Console.ReadLine(); } }

1 Answers  


What is default constructor in c#?

0 Answers  


What is a Command Object in C#?

0 Answers   B-Ways TecnoSoft,


What is difference between destructor and finalize?

0 Answers  


How is the syntax written to inherit from a class in C#?Give an example ?

0 Answers   Siebel,






what is IDisposal interface

0 Answers   Wipro,


What is the benefit of delegate in c#?

0 Answers  


What is a service layer c#?

0 Answers  


Is linkedhashset synchronized?

0 Answers  


What is window application in c#?

0 Answers  


Can we inherit private members of class in c#?

0 Answers  


What is difference between array and list?

0 Answers  


Categories