❔ Need help with datetime
I need to create a class which has two fields; name and date. Then create objects of this class. I need to use datetime for the date field. anyone knows what im doing wrong?
so basically;
so basically;
static void Main()
{
//create intances of Employee;
Employee emp1 = new Employee("James", 25, new DateTime(2000, 5, 1));
//add employees to list
List<Employee> employees = new List<Employee>(4);
employees.Add(emp1);
//LINQ Questions;
//Q1. Return a List of employees that hired after the year 2005
var queryHiredAfter2005 = from emp in employees
where emp.HireDate.Year > 2005
select emp.Name;
foreach (var res in queryHiredAfter2005)
{
Console.WriteLine(res);
}
class Employee
{
public string name;
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public DateTime hiredate;
public DateTime HireDate { get; set; }
//Constructor;
public Employee(string _name, int _age, DateTime _hiredate)
{
_name = Name;
_age = Age;
_hiredate = HireDate;
}