My thoughts regarding ASP.NET, C#, programming practices, and more...
reading
You Should Read archives
blogs I read
|
Wednesday, April 27, 2005Nullable Type Performance
David M. Kean has an excellent posting on his blog regarding the performance of Nullable Types in .Net Framework 2.0 Beta 2.
Content copyright ©2003-2006 Tod Birdsall
It appears that the summary of the reports would indicate that nullable types can be up to 50% slower (integer types). However, I tend to agree with some of the comments made on the blog posting. If you prefer to use a nullable data type, is it any slower than implementing your own solution? I have used a custom class called NullableDateTime, which served as a custom solution to the lack of Nullable types in the 1.1 .Net Framework. For quite some time now, I have leaned away from custom nullable types, and instead I default integer variables to -1 to indicate that no value has been assigned. In the case of DateTime types, I simply check to see if the value is greater than DateTime.MinValue. I am not sure I will change my method any time soon. On the positive side, the post also includes benchmarks for Generic List |