program to work with User Defined Default Constructor
program to work with User Defined Default Constructor:
Class Diagram:
employee1
|
Int EmpId
String EName
String EAddress
Int EAge
|
Public employee1()
Public void DisplayEmpData()
|
using System;
using System.Collections.Generic;using System. Linq;
using System.Text;
namespace CAConstructors
{
class employee1
{
int Empid, Eage;
string Ename, Eaddress;
public employee1()
{
Console.WriteLine("Enter Employee Detailes:-");
this.Empid = 101;
this.Ename = "srikanht";
this.Eaddress = "Hyderabad";
this.Eage = 25;
}
public void DisplayEmpdata()
{
Console.WriteLine("Employee id is :-"+Empid);
Console.WriteLine("Employee Name is :-" + Ename);
Console.WriteLine("Employee Adderse is :-" +Eaddress);
Console.WriteLine("Employee age is :-" + Eage);
}
}
class UDConstructor
{
static void Main(string[] args)
{
employee1 obj1 = new employee1();
employee1 obj2 = new employee1();
obj1.DisplayEmpdata();
obj2.DisplayEmpdata();
Console.ReadLine();
}
}
}
Output:-
0 comments:
Post a Comment