我有一个有4个值的枚举:
public enum DriveRates
{
driveSidereal = 0,
driveLunar = 1,
driveSolar = 2,
driveKing = 3
}
Run Code Online (Sandbox Code Playgroud)
我有一个值数组,我想要转换为DriveRates数组.然而,当我这样做时var rates = (DriveRates[])ret;,它ret是一个数字对象数组(可能是整数),它说Unable to cast object of type 'System.Object[]' to type 'ASCOM.DeviceInterface.DriveRates[]'.
ret= {0,1,2,3}.我应该怎么做呢.再次,我试图将枚举值数组转换为枚举数组......好吧,值:)但我正在尝试从类型转换object[]为类型DriveRates[].