How to make the next extension? I bind a ComboBoxe to an enumeration, in which case it does not compile, because it returns null .
public static T GetSelectedValue<T>(this ComboBox control) { if (control.SelectedValue == null) return null; return (T)control.SelectedValue; }
Note. I want it to return null (instead of the default value (T)). The question is, where is the expression that I should use?
source share