Constructor Overloading Source

  Source Code:- 

using A = System.Console; 

public class ConstOverloading 

{     

int x; 

    public ConstOverloading(int a, int b) 

    { 

        A.WriteLine(a + b); 

    } 

    public ConstOverloading(float a, float b) 

    { 

        A.WriteLine(a + b); 

    } 

    public ConstOverloading() 

    { 

        int x = 5; 

        A.WriteLine(x + x); 

    } 

class Demo { 

    static void Main(string[] args) 

    { 

        ConstOverloading c1 = new ConstOverloading(7, 8); 

        ConstOverloading c2 = new ConstOverloading(34.5f, 20.8f); 

        ConstOverloading c3 = new ConstOverloading(); 

        A.ReadKey(); 

    }  

Output:-



Post a Comment

0 Comments