Home > DeveloperSection > Beginner > Constructor in C#

Constructor in C#


ASP.Net ASP.Net 
Ratings:
0 Comment(s)
 2138  View(s)
Rate this:

Constructor in C#

Constructor is like a method.

1. Constructor has the same name as a class name.

2. Constructor doesn’t have any return type.

3. Constructor didn’t call by programmer it is called automatic whenever class object is created.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace ConsoleApplication4

{

    class Program

    {

        public static void Main(string[] args)

        {

            ABC OBJ = new ABC();

 

        }

    }

 

    class ABC

    {

        public ABC()

        {

            Console.WriteLine("Constructor Called");

        }

    }

}

 


Don't want to miss updates? Please click the below button!

Follow MindStick