Convert.ChangeType wrapper that handles nullable types

As I mentioned before, the Convert.ChangeType method doesn't handle nullables. One of the comments proposed a replacement, but I preferred to have a wrapper around the original Convert.ChangeType method, so in general it would behave identical to Convert.ChangeType, except that it would handle nullable types as well instead of throwing an InvalidCastException.

I wrote, compiled, and tested such a wrapper finally, and posted it as a CodeSnip article on ASP Alliance, where I've also been an author for over five years. Check out my ChangeType method, use it, let me know what you think! Oh, and if anyone on the CLR team is reading this post, feel free to incorporate my wrapper in the next .NET Framework service pack. ;-)

Special thanks to a fellow ASP Alliance author, the multiple blog-having J. Ambrose Little and alert reader, Google user, weblogs.asp.net surfer, and my brother, Toby Johnson for helping me put together this method.

6 Comments

Comments have been disabled for this content.