Reputation: 19
I'm new to C# but trying to use an enum. The enum is as follows:
public enum PARAM : int { ROLL = 1, PITCH, YAW, MAGX, MAGY, MAGZ, BCA, OAT, IAS, TAS, VOLTS, AOA };
I'm using it as follows:
AhrsCom.setCommand("$out=" + PARAM.PITCH + ",10\n\r");
However, it passes the following string to setCommand(string command)
:
"$out=PITCH,10\n\r"
Instead of out=2,10\n\r
, as I thought it would.
Upvotes: 1
Views: 224
Reputation: 1822
You can cast this way:
AhrsCom.setCommand("$out=" + (int)PARAM.PITCH + ",10\n\r");
Upvotes: 0
Reputation: 310983
You can cast the enum to an int
to gets it numeric value:
AhrsCom.setCommand("$out=" + (int)PARAM.PITCH + ",10\n\r");
Upvotes: 1
Reputation: 50110
you need
AhrsCom.setCommand("$out=" + (int)PARAM.PITCH + ",10\n\r");
to say you want the number, not the string
Upvotes: 1