Je suis en train de relire un certain nombre de propriétés dans le constructeur d'un objet. L'une des propriétés est calculée à partir d'une autre propriété.Comment ajouter assigner une valeur de propriété calculée à un objet?
Mais quand je crée cet objet la valeur calculée Implementation_End_String
valeur de la propriété est toujours nulle:
private string implementationEndString;
public string Implementation_End_String {
get{
return implementationEndString;
}
set {
implementationEndString= DataTimeExtensions.NullableDateTimeToString(Implementation_End);
}
}
Question:
Comment pouvez-vous passer dans une propriété calculée à un constructeur d'objet?
C'est un point essentiel de la cteur et propriété calculée:
private string implementationEndString;
public string Implementation_End_String {
get{
return implementationEndString;
}
set {
implementationEndString= DataTimeExtensions.NullableDateTimeToString(Implementation_End);
}
}
public DateTime? Implementation_End { get; set; }
public ReleaseStatus(DateTime? implementationEnd)
{
//value is assigned at runtime
Implementation_End = changeRequestPlannedImplementationEnd;
}
double possible de [? Qu'est-ce qu'un NullReferenceException, et comment puis-je résoudre ce problème] (http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – mybirthname