What is constructor How to use constructor
what is constructor
Constructor is a special type of method which name is same as class name .when we create a object of class then the method called automatically.The following example of constructor-
using System;
using System.Collection. Generic;
using System.Text;
namespace keshav
{
class Ravi
{
public Ravi()
{
Console.WriteLine("Always work hard ");
}
public static void Main(string[]args)
{
Ravi rs=new Ravi();
}
}
}
No comments: