My sample code for solving this problem:
public class Person
{
private DateTime _date;
public string Name { get; set; }
public DateTime DateOfBirth { get { return _date.Date; } set { _date = value; } }
}
class Program
{
static void Main(string[] args)
{
Person p = new Person();
p.Name = "AAA";
p.DateOfBirth = new DateTime(2005,3,2,5,5,5);
Console.WriteLine(p.DateOfBirth);
Console.ReadKey();
}
}
In this case output is:
02.03.2005 00:00:00
Technically it removed the time, but still returns 00:00:00 as an hour. How can i actually get rid of time? A lot of people post this as solution, but it doesn't really solve the problem.
My expected output is:
02.03.2005