22 Sep 2017

What is Default Constructor in C sharp


A Constructor not Parameterized is called a default Constructor.

Example of Default Construtor:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace what_is_default_constructor
{
    class Rock
    {
        int a = 20, b = 60, c;

        public Rock()
        {
            c = a + b;
            Console.WriteLine(c);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Rock Rock1 = new Rock();
            Console.ReadKey();
        }
    }
}

No comments:
Write comments

Contact Form

Name

Email *

Message *

© 2014 Rock Programmer . Designed by Bloggertheme9
Powered by Rock Programmer.