【发布时间】:2017-07-14 11:31:43
【问题描述】:
我是 C# 新手,但尝试使用枚举。枚举如下:
public enum PARAM : int { ROLL = 1, PITCH, YAW, MAGX, MAGY, MAGZ, BCA, OAT, IAS, TAS, VOLTS, AOA };
我是这样使用的:
AhrsCom.setCommand("$out=" + PARAM.PITCH + ",10\n\r");
但是,它将以下字符串传递给setCommand(string command):
"$out=PITCH,10\n\r"
而不是out=2,10\n\r,就像我想的那样。
【问题讨论】:
-
如果您想将枚举用作
int,请将其转换为int -
使用 AhrsCom.setCommand("$out=" + (int)PARAM.PITCH + ",10\n\r");