Thursday, July 11, 2013

METHOD OVERLOADING IN C#.

//Method Overloding :
//The Methods having the same name .. but different signature
//Signature : Number of parameters and Types of parameters
//Return type is not included in signature..
//Return type change : not overloding ...erororororo
class a
{
    //private attribute
    int x;
    public void display()
    {
        x=9999;
        System.Console.WriteLine("x="+x);
    }
    /* erorororororooror
    public int display()
    {
        x=9999;
        System.Console.WriteLine("x="+x);
        return 999;
    }
    */
    public void display(int p)
    {
        x=p;
        System.Console.WriteLine("x="+x);
    }
    public void display(int p,int q)
    {
        x=p+q;
        System.Console.WriteLine("x="+x);
    }
}
class b
{
    public static void Main()
    {
        a z=new a();
        z.display();
        z.display(222);
        z.display(33,33);
       
    }
}


No comments:

Post a Comment