protected void MakeAutoComplete(ref Control control, IListSource dListSource)
{
MakeAutoComplete(ref control, dListSource, false);
}
protected void MakeAutoComplete(ref Control control, IListSource dListSource, bool isComboBox)
{
var curControl = (isComboBox) ? (control as ComboBox) : (control as TextBox);
// other
}
在var curControl
VS 的线上给了我错误
Type of conditional expression cannot be determined because there is no implicit conversion between 'System.Windows.Forms.ComboBox' and 'System.Windows.Forms.TextBox'
,我可以理解错误,而且我知道没有强制转换TextBox
和ComboBox
,但这就是我var
首先使用的原因。所以有什么问题?为什么抱怨?