|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace inheritance
{
public partial
class frmEmpDetails
: Form
{
public frmEmpDetails()
{
InitializeComponent();
}
class Employee
// creating class employee
{
public int
EmpID
//define the property of variables EmpID
{
get;
set;
}
public string
Name
//define the property of variable Name
{
get;
set;
}
public string
FatherName //define the property of
variable FatherName
{
get;
set;
}
public string
Designation
//define the property of variable Designetion
{
get;
set;
}
public Employee()
//constructor of Employee class to give their default value
{
EmpID = 0;
Name = "";
FatherName = "";
Designation = "";
MessageBox.Show("Call Employee class constructor.....");
}
public void
Display()
//creating function called Display
{
MessageBox.Show("Employee class Display function....\nempleyee id.."
+ EmpID + "\nemployee name.." + Name +
"\nemployee father name..." + FatherName +
"\nemployee desigination..." + Designation);
}
}
class Type :
Employee
//child class Type inherrite the base class
Employee
{
public string
TypeName
//define the property of Type_Name
{
get;
set;
}
public Type()
//constructor of Type class
{
TypeName = "";
MessageBox.Show("Call Type class constructor.....");
}
public void
Show()//creating function called Show
{
Display();//call the function of Employee class
Displsy
MessageBox.Show("Type class Show funtion...\nemployee type..."
+ TypeName);
}
}
private void
buttonSubmit_Click(object sender,
EventArgs e)
{
Type t1 = new
Type();//define the
object of derived class
//here we can use the base class variables by creating object of Type class
t1.EmpID = Int32.Parse(txtEmpId.Text);
t1.Name= txtName.Text;
t1.FatherName = txtEmpFatherName.Text;
t1.Designation = txtDesignation.Text;
t1.TypeName = txtEmaployeetype.Text;
t1.Show();//call the derived class method
}
}
}
|