While building our Commerce Server 2007 solution it made sense to wrap the LineItem class to easily access the weakly typed indexer accessible properties (which are exposed as object).
Because the underlying datatype could have been anything (ref/value type, nullable, custom) I created a helper method that accepts an object value and returns the value casted to the appropriate type. The can obviously be used in many contexts so I thought I’d share.
public static T ConvertTo(object value)
Use of included code sample is subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
This posting is provided “AS IS” with no warranties, and confers no rights.