Constructor Overloading in .NET

class test
    {
        public test(int a)
        {
            Console.WriteLine("value of a is {0}", a);
        }

        public test()
        {
            Console.WriteLine("Default Constructor OR No Parameter Constant");
        }

        public void display()
        {
            Console.WriteLine("In a display TEST");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            test obj1 = new test(10);
            obj1.display();

            test obj = new test();
            obj.display();

            Console.Read();
        }
}

SHARE THE KNOWLEDGE


  

Advertisements

About Dinesh

I am engineering student........ I am selected in Microsoft Student Partner as MSP............

Posted on August 5, 2011, in .NET, Knowledge. Bookmark the permalink. Leave a comment.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: