c# c++数据类型对照

最近再做c#调用c++编写的dll。在网上查了查两者的数据对照,自己再重新总结一遍,可能会有重复或者多种方案。如果有错误希望大家给提出,反正我也不改!

 

c++                                                                              c#                                            

HANDLE(void *) ----------------------------------------System.IntPtr

Byte(unsigned char) ----------------------------------System.Byte

SHORT(short) ------------------------------------------System.Int16

WORD(unsigned short) -----------------------------System.UInt16

INT(int) ---------------------------------------------------System.Int16

INT(int) ---------------------------------------------------System.Int32

UINT(unsigned int) -----------------------------------System.UInt16

UINT(unsigned int) -----------------------------------System.UInt32

LONG(long) -------------------------------------------- System.Int32

ULONG(unsigned long) ---------------------------- System.UInt32

DWORD(unsigned long) ----------------------------System.UInt32

DECIMAL ------------------------------------------------ System.Decimal

BOOL(long) ---------------------------------------------System.Boolean

CHAR(char) ---------------------------------------------System.Char

LPSTR(char *) ------------------------------------------System.String

LPWSTR(wchar_t *) -----------------------------------System.String

LPCSTR(const char *) --------------------------------System.String

LPCWSTR(const wchar_t *) -------------------------System.String

PCAHR(char *) -------------------------------------------System.String

BSTR --------------------------------------------------------System.String

FLOAT(float) -----------------------------------------------System.Single

DOUBLE(double) -----------------------------------------System.Double

VARIANT -----------------------------------------------------System.Object

PBYTE(byte *) -----------------------------------------------System.Byte[]

BSTR ----------------------------------------------------------StringBuilder

LPCTSTR ---------------------------------------------------- StringBuilder

LPCTSTR ---------------------------------------------------- string

LPTSTR -------------------------------------------------------[MarshalAs(UnmanagedType.LPTStr)] string

LPTSTR 输出变量名 --------------------------------------StringBuilder 输出变量名

LPCWSTR --------------------------------------------------- IntPtr

BOOL ----------------------------------------------------------bool

HMODULE ---------------------------------------------------IntPtr

HINSTANCE -------------------------------------------------IntPtr

结构体 --------------------------------------------------------public struct 结构体{};

结构体 **变量名 -------------------------------------------out 变量名 //C#中提前申明一个结构体实例化后的变量名

结构体 &变量名 ------------------------------------------- ref 结构体 变量名

WORD --------------------------------------------------------ushort

DWORD ------------------------------------------------------uint

DWORD ------------------------------------------------------int

UCHAR -------------------------------------------------------int

UCHAR -------------------------------------------------------byte

UCHAR* -----------------------------------------------------string

UCHAR* -----------------------------------------------------IntPtr

GUID ----------------------------------------------------------Guid

Handle --------------------------------------------------------IntPtr

HWND --------------------------------------------------------IntPtr

DWORD ------------------------------------------------------int

COLORREF -------------------------------------------------uint

unsigned char ----------------------------------------------byte

unsigned char * --------------------------------------------ref byte

unsigned char * --------------------------------------------[MarshalAs(UnmanagedType.LPArray)] byte[]

unsigned char * --------------------------------------------[MarshalAs(UnmanagedType.LPArray)] Intptr

unsigned char & --------------------------------------------ref byte

unsigned char ----------------------------------------------byte

unsigned short --------- -----------------------------------ushort

unsigned int --------------------------------------------------uint

unsigned long -----------------------------------------------ulong

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值