Apparently you can’t have a Nullable<Rectangle> in Silverlight. I’d like to know the technical reasons why not and how many objects this may apply to?
Today I accidentally started a small comment flamewar after stating that the “Rectangle” type was not a Nullable type. That is you can’t have a “Nullable<Rectangle>” or a “Rectangle?“
My mistake was in testing it in Silverlight only and assuming that the behaviour of a Silverlight System.Windows.Shapes.Rectangle carried over to the System.Drawing.Rectangle type in .Net. Shame on me. I have since deleted my comments as they added no value to Stack Overflow.
If anyone can answer this question fully it would be much appreciated.
Nullable<T>can only be used with value types, or structs, and System.Windows.Shapes.Rectangle is a reference type, or class. You don’t need to useNullable<T>, since you can already assign a null reference to a variable of type System.Windows.Shapes.Rectangle:By contrast, System.Drawing.Rectangle is a value type, so it cannot have a value of null. The default value is a rectangle of all zeros.