Conversion between Nullable types
问题 Is there a converter in .NET 4.0 that supports conversions between nullable types to shorten instructions like: bool? nullableBool = GetSomething(); byte? nbyte = nullableBool.HasValue ? (byte?)Convert.ToByte(nullableBool.Value) : null; 回答1: Not that I am aware of. You could just write a helper method like this: public Nullable<TTarget> NullableConvert<TSource, TTarget>( Nullable<TSource> source, Func<TSource, TTarget> converter) where TTarget: struct where TSource: struct { return source