I've built a wrapper over NumbericUpDown control. The wrapper is generic and can support int? and double?
I would like to write a method that will do the following.
public partial class NullableNumericUpDown<T> : UserControl where T : struct
{
private NumbericUpDown numericUpDown;
private T? Getvalue()
{
T? value = numericUpDown.Value as T?; // <-- this is null :) thus my question
return value;
}}
of course there is no cast between decimal and double? or int? so I need to use a certain way of converting. I would like to avoid switch or if expressions.
What would you do?
To clarify my question I've provided more code...