求教 c++部分代码相对应的c#里的代码怎么写~
找到一个C的源码,我想把它搬到c#里来用,但是这段不懂。
源码内:
#include <wintab.h>
#define PACKETNAME MOE
#define MOEPACKETDATA PK_X | PK_Y | PK_BUTTONS /* x, y, buttons */
#define MOEPACKETMODE PK_BUTTONS /* buttons relative mode */
...
后续会用到 MOEPACKETDATA 和 MOEPACKETMODE
PK_X,PK_Y,PK_BUTTONS 换到c#里定义到枚举里了,
public enum WTPKT
{
PK_CONTEXT = 0x0001,/* reporting context */
PK_STATUS = 0x0002,/* status bits */
PK_TIME = 0x0004,/* time stamp */
PK_CHANGED = 0x0008,/* change bit vector */
PK_SERIAL_NUMBER = 0x0010,/* packet serial number */
PK_CURSOR = 0x0020,/* reporting cursor */
PK_BUTTONS = 0x0040,/* button information */
PK_X = 0x0080,/* x axis */
PK_Y = 0x0100,/* y axis */
PK_Z = 0x0200,/* z axis */
PK_NORMAL_PRESSURE = 0x0400,/* normal or tip pressure */
PK_TANGENT_PRESSURE = 0x0800,/* tangential or barrel pressure */
PK_ORIENTATION = 0x1000,/* orientation info: tilts */
PK_ROTATION = 0x2000/* rotation info; 1.1 */
}
求教,
#define PACKETDATA (PK_X | PK_Y | PK_BUTTONS)
#define PACKETNAME MOE
#define PACKETDATA PK_X | PK_Y | PK_BUTTONS
#define PACKETMODE PK_BUTTONS
像这样的用法,表示什么意思?在c#里应该怎么定义?
求对应的c#代码,或者讲解~ C++ C#
[解决办法]
#define在c++中是定义宏,c#也有#define但只能定义一个符号,所以c#的#define像c++那样用,
c#没有宏替换机制,所以只能把c++的宏定义为方法或者属性,
比如#define PACKETDATA (PK_X
[解决办法]
PK_Y
[解决办法]
PK_BUTTONS)可以对应:
int PACKETDATA
{
get{return PK_X
[解决办法]
PK_Y
[解决办法]
PK_BUTTONS;};
}
[解决办法]
#define是宏。
在C#中用
const int(或者其他类型) 应该就可以。
const int MOEPACKETDATA = PK_X
[解决办法]
PK_Y
[解决办法]
PK_BUTTONS;