Wednesday, August 23, 2017

Constructor

Constructors are used to initializing the values. In C# constructors name is same as that of the class name.constructors activate automatically as the class object activated. it has no return type as it returns nothing. it saves the memory space. it activates at run time.


Example:

class We
{
   int value;
    public We(int value)
    {
        size = value;
    }
}

class Program
{
    static void Main()
    {
        We wid = new We(101);
     
    }
}

No comments:

Post a Comment