using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programming_Console
{
/// <summary>
/// using Properties
/// </summary>
class Employee
{
public int Age { get; set; }
public string Name { get; set; }
public double Salary { get; set; }
public DateTime dt { get; set; }
public string phone { get; set; }
public void bonus(double bonusme)
{
Salary += Salary * bonusme;
}
//Constructor defination
public Employee(int age, string name, double salary, DateTime DT, string Phone)
{
Age = age;
Name = name;
Salary = salary;
dt = DT;
phone = Phone;
}
public Employee()
{
}
}
class Program
{
static void Main(string[] args)
{
Employee emp = new Employee()
{
Age = 11,
Name = "Ujjwal Patel",
Salary = 700000.00,
dt = new DateTime(2015, 01, 17),
phone = "9004210768"
};
Console.WriteLine("Employee: {0} of Age {1} with Salary {2} and Conact Number {3} is hired on Date {4}", emp.Name, emp.Age, emp.Salary, emp.phone, emp.dt.Date);
emp.bonus(0.05);
Console.WriteLine("Employee has bonus of {0}", emp.Salary);
Employee Tracy = new Employee(25, "Tracy", 30000, new DateTime(2015, 1, 14), "9004218068");
Console.WriteLine("Employee: {0} of Age {1} with Salary {2} and Conact Number {3} is hired on Date {4}", Tracy.Name, Tracy.Age, Tracy.Salary, Tracy.phone, Tracy.dt.Date);
Console.ReadKey();
}
}
}This code show how to Create Instance and Populate Data using Constructor.
