Users Pricing

articles

home / developersection / articles / constructor in c#

Constructor in C#

umesh Sharma 5918 28 Jun 2014 Updated 11 Jul 2020

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

 


umesh Sharma

Other

I'm a student