Program with System Defined Default Constructor code example in oops in C# dot net
Program with System Defined Default Constructor code example in oops in C# dot net : in this Program we will give the example program of System Defined Default Constructor . so please follow below code and run in your dot net software
Program with System Defined Default Constructor:
Diagram:
employee2
|
Int EmpId
String EName
String EAddress
Int EAge
|
Public void DisplayEmpData()
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CAConstructors
{
class employee2
{
int Empid, Eage;
string Ename, Eaddress;
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 SDConsttructor
{
static void Main(string[] args)
{
employee2 obj1 = new employee2();
employee2 obj2 = new employee2();
obj1.DisplayEmpdata();
obj2.DisplayEmpdata();
Console.ReadLine();
}
}
}
Output:
Both default constructors have a drawback that for number of objects created to the class all objects will store for same data in their referenced data fields.
To over come this draw back we use parameterized constructor.
0 comments:
Post a Comment