Possible Duplicate:
? (nullable) operator in C#
In System.Windows.Media.Animation I see the code as follows:
public double? By { get; set; }
What does the ? operator do here? Does anyone know?
I’ve tried to google this but it’s hard to search for the operator if you don’t know what its called by name. I’ve checked the page on Operators (http://msdn.microsoft.com/en-us/library/6a71f45d(v=vs.80).aspx) but the ? operator is not listed there.
Thanks!
The
?is a type decorator.T?is the same asNullable<T>, i.e. a nullable value type.The documentation of the
Byproperty explains why it’s used here:The property controls how A
DoubleAnimationprogresses; but instead of setting theByproperty, you can also set theFromandToproperties (or either) to control animation progress. Every combination of properties (exceptToandBy) is allowed, so there needs to be a way to signal that a property is not set – hence it’s nullable.