Blog Stats
  • Posts - 7
  • Articles - 0
  • Comments - 3
  • Trackbacks - 4

 

Monday, February 27, 2006

Nullable Types in C# 2.0


I'll have to refactor our team's “Software Factory” custom framework generator. It originally built in support for object generation to support null for value types. We achieved this by storing bit values to correspond to the member fields. This allowed us to have an object's property like object.Length and determine if it was null by having corresponding properties test for nullability.

int? length = null ... will essentially define a nullable int by C#'s mapping of int? to Nullable generic.

The boxing handling for the Nullable types is pretty interesting but I want to do more digging under the covers and will repost some findings before I migrate our factory system from the 1.1 framework to 2.0.

For more cool 2.0 changes (reference), this post by Patrick lists some pretty good stuff.

http://www.codeproject.com/books/net2_cs2_newfeatures.asp

 

 

Copyright © Marlon Rabara