Practical : 9
Subject : .Net
Source Code :
Subject : .Net
Aim : C# program to print student details using constructor and destructor.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace dotnet008
{
class
pub_constructor
{
public
pub_constructor()
{
Console.WriteLine("Student Details");
}
}
class pra9
{
private
pra9(string name, string enrl, string sub)
{
Console.Write("student name : {0} \nstudent enrl : {1} \nsubject :
{2}",name,enrl,sub);
}
~pra9()
{
Console.WriteLine("Destructor is called");
}
static void
Main(string[] args)
{
pub_constructor p1 = new pub_constructor();
pra9 p2 =
new pra9("Pratik Boghani", "171230107008",
"Dot-Net");
Console.ReadKey();
}
}
}
Output :
Output :
0 comments:
Post a Comment