.Net Practical 9

Practical : 9
Subject : .Net

Aim : C# program to print student details using constructor and destructor.

Source Code :
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 :


Pratik Boghani

Author & Editor

Life is all about the next step.

0 comments:

Post a Comment