5
I have a record of people where I need to store birth dates (DateBirth
) and death (DateDeath
). Knowing that the guy DateTime
in C# cannot be empty and its default initial value is 01/01/0001 00:00:00, which makes no sense to fill in a field that deals with a person’s death date, which solution you would apply?
They would still define the property as the type DateTime
and would do some kind of treatment afterwards? They would define it as string
? Or what other solution they might suggest?
Below, excerpt from entity class code in C#.
public class Person
{
public string Name { get; set; }
public string Gender { get; set; }
public DateTime DateBirth { get; set; }
// Definir a propriedade como DateTime há um valor inicial pré-definido: 01/01/0001
// public DateTime DateDeath { get; set; }
// Ou definir a propriedade como string, iniciando-a com valor vazio,
// mas sem os recursos de validação do tipo DateTime.
// public string DateDeath { get; set; }
}
Thanks for the help Maniero. I will follow your tip!
– Carlos Wanderley