What is overloading and how can this be done ?




Answers were Sorted based on User's Feedback



What is overloading and how can this be done ?..

Answer / rashid

Overloading is the process of call the same method with
different parameter types,diferent order of parameters with
in the class.Its also applicable for the constructor.

here i give some example

class sample
{
public void display()
{
Console.WriteLine("display :1");
}
public void display(int i,int j)
{
int s=0;
s = i+j;
Console.WriteLine("Result :"+s);
}
}

class Overload
{
public static void Main(string []args)
{
sample s = new sample();
s.display();
s.display(5,5);
}

Is This Answer Correct ?    5 Yes 0 No

What is overloading and how can this be done ?..

Answer / mahesh babu ummaneni

overloading is nothing but method name is same but perameters is different.
for example
class overloading
{
public void add(int x)
{
console.writeline("sum");
}
public void add(int x,int y)
{
console.writeline("THE SUM IS:"+(x+y));
}
}

Is This Answer Correct ?    1 Yes 0 No

What is overloading and how can this be done ?..

Answer / rajesh

the above one is absolutely right

Is This Answer Correct ?    0 Yes 0 No




What is overloading and how can this be done ?..

Answer / senthil kumar

Overloading is the process of call the same method with
different parameter types,diferent order of parameters with
in the class.Its also applicable for the constructor.

here i give some example

class sample
{
public void display()
{
Console.WriteLine("display :1");
}
public void (int i,int j)
{
int s=0;
s = i+j;
Console.WriteLine("Result :"+s);
}
}

class Overload
{
public static void Main(string []args)
{
sample s = new sample();
s.display();
s.display(5,5);
}
}

Is This Answer Correct ?    0 Yes 4 No

Post New Answer



More C Sharp Interview Questions

what is a template?

3 Answers   Choice Solutions,


which access modifier we can declare the abstract class?

5 Answers   IBM,


What is GAC?

1 Answers   Cognizant,


what is method overloading in c#?

0 Answers   Arigo Infotech,


int a = '3' + '4'; char n = (char)a; What will be answer of n?

4 Answers  






About multi level and multiple inheritance how to achieve in .net ?

2 Answers   CTS, MMTS,


What is the implicit name of the parameter that gets passed into the set method/property of a class?

0 Answers   Siebel,


why C#.net doesnot support prcedures and why it supports structs,functions

1 Answers  


Does C# support multiple inheritance?

5 Answers  


What is Delay Signing?

1 Answers   ACS,


int i,string s, String s1 Which is valuetype which is refrence type.

6 Answers   Synechron, Sytel,


What is scavenging?

2 Answers   HCL,






Categories