articles

Home / DeveloperSection / Articles / Constructor in C#

Constructor in C#

umesh Sharma5283 28-Jun-2014

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");
        }
    }
}

 


Updated 11-Jul-2020
I'm a student

Leave Comment

Comments

Liked By