24.Default Constructor in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace default_constructor.cs
{
class defcon
{
int no;
String nm;
public defcon()
{
no = 1;
nm = "Milan";
}
public void display()
{
Console.WriteLine(no);
Console.WriteLine(nm);
}
}
class Program
{
static void Main(string[] args)
{
defcon obj = new defcon();
obj.display();
Console.Read();
}
}
}
OUTPUT:
1
Milan
Comments
Post a Comment