using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ComplexDemoOnConstructorsAndDestructors
{
class Student
{
//private data members
private int StudentID;
private string StudentName;
//default constructor
public Student()
{
StudentID = 101;
StudentName = "varshini";
}
//parameterized constructor
public Student(int StudentID, string StudentName)
{
this.StudentID = StudentID;
this.StudentName = StudentName;
}
//copy constructor
public Student(Student s)
{
StudentID = s.StudentID;
StudentName = s.StudentName;
}
//destructor
~Student()
{
Console.WriteLine("This is destructor...");
}
//public method
public void Display()
{
Console.WriteLine(StudentID + ", " + StudentName);
}
}
class Program
{
static void Main(string[] args)
{
//invoke default constructor
Student s1 = new Student();
s1.Display();
//invoke parameterized constructor
Student s2 = new Student(102, "sateesh");
s2.Display();
//invoke copy constructor
Student s3 = new Student(s1);
s3.Display();
Console.Read();
}
}
}