i know what is the maening for method overloading ....can any one explain me method overloading with real time .NET example plz

Recommended Answers

All 4 Replies

You've million dozens of examples for method overloading, and if you develop business applications you'll feel that. But let me give you an example; object initiation, you need some object(s) or none to initiate object, let's see SqlCommand class constructors, it let the developer initiate the class with whatever proper of objects he has\likes...

simply, you can create multiple methods of the same name, that accept different params, depending on what arguments you pass to your method, something specialized occurs.

example:

public static setTitle(string s)
{
     this.Text = s;
}

public static setTitle(string s, boolean alertUser)
{
     this.Text = s;
     if(alertUser == true)
     {
         messageBox.Show("form caption changed to "+s);
      }
}

happy coding

Here is a list of overloads for Convert.ToInt32() from the .NET framework.

public static int ToInt32(DateTime value);
public static int ToInt32(bool value);
public static int ToInt32(byte value);
public static int ToInt32(char value);
public static int ToInt32(decimal value);
public static int ToInt32(double value);
public static int ToInt32(float value);
public static int ToInt32(int value);
public static int ToInt32(long value);
public static int ToInt32(object value);
public static int ToInt32(object value, IFormatProvider provider);
public static int ToInt32(sbyte value);
public static int ToInt32(short value);
public static int ToInt32(string value);
public static int ToInt32(string value, IFormatProvider provider);
public static int ToInt32(string value, int fromBase);
public static int ToInt32(uint value);
public static int ToInt32(ulong value);
public static int ToInt32(ushort value);

i know what is the maening for method overloading ....can any one explain me method overloading with real time .NET example plz

In real world, we have a common verb serves different meaning.
For example,
to print

  • Print on printer
  • Print on screen
  • Print on disk/file

All three activities requires different actions but they uses common name (print).

In context of OOP, the term Overload is also know as polymorphism. Meaning of polymorphism is that an entity has multiple forms.

It is possible to define the same function twice while using different parameter for each definition.

commented: In two threads you have picked apart the use of the english language while not contributing any beneficial suggestions. Try helping the users and laying off the criticism +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.