nullable Duration.TimeStamp?  
Author Message
Brandon Furtwangler





PostPosted: Windows Presentation Foundation (WPF), nullable Duration.TimeStamp? Top

Why does Duration have a HasTimeStamp property instead of a nullable TimeStamp property



Visual Studio 200844  
 
 
Brandon Hamm





PostPosted: Windows Presentation Foundation (WPF), nullable Duration.TimeStamp? Top

Purely speculating here (I don't have access to docs...or at least I couldn't find any to confirm my assumptions). If the Timestamp property gets/sets a DateTime --> know that DateTime is a value type - not a reference type, and therefore is not nullable.

Hope it helps...
-Brandon


--
Brandon Hamm


 
 
Brandon Furtwangler





PostPosted: Windows Presentation Foundation (WPF), nullable Duration.TimeStamp? Top

You can have nullable value types, so I dont see why it matters if it uses DateTime internally or not.

My issue is that Duration has a non nullable property called TimeStamp. But if you set the duration to Duration.Forever or Duration.Automatic it will tell you this setting Duration.HasTimeStamp to false. This seems to me like they are emulating the behavior that nullable types are suppose to provide.

For example, I believe Duration should not have a HasTimeStamp property, but instead have a nullable TimeStamp property. Then if you set the duration to automatic, the TimeStamp will be set to null. In other words, why are they emulating a nullable type with the HasTimeStamp property when they are targeting .net 2.0 and thus could simply use the same idiom as everyone else.


 
 
Brandon Hamm





PostPosted: Windows Presentation Foundation (WPF), nullable Duration.TimeStamp? Top

A quick check of my information reveals you're right....with .NET 2.0 you are able to have nullable value types...my mistake :-/

In this case...I completely agree...I don't see the point either.

Later,
Brandon