I just got the following error:
There is no implicit conversion between 'ViewModelA' and 'ViewModelB'
.
This error occured while trying to implement the following line of code:
ViewModel myViewModel = conditionIsTrue() ? _viewModelA : _viewModelB;
Both of the ViewModels inherits from ViewModel but are two different subclasses.
However, if I avoid the ?-operator and use if/else instead it works:
ViewModel myViewModel;
if (conditionIsTrue(){
myViewModel = _viewModelA;
}else{
myViewModel = _viewModelB;
}
Could you tell me why this happens?