I am getting the following error:
Type of conditional expression cannot be determined because there is no implicit conversion between 'Car' and 'Bike'
public interface IVehicle
{
int Wheels { get; }
}
public class Car : IVehicle
{
public int Wheels => 4;
}
public class Bike : IVehicle
{
public int Wheels => 2;
}
public Garage()
{
var licenseHeld = false;
IVehicle vehicle = licenseHeld ? new Car() : new Bike();
}
Why cannot this conversion be done when both Car and Bike implement the same interface?