首页 > 代码库 > c++转C#
c++转C#
1 //c++:HANDLE(void *) ---- c#:System.IntPtr 2 //c++:Byte(unsigned char) ---- c#:System.Byte 3 //c++:SHORT(short) ---- c#:System.Int16 4 //c++:WORD(unsigned short) ---- c#:System.UInt16 5 //c++:INT(int) ---- c#:System.Int16 6 //c++:INT(int) ---- c#:System.Int32 7 //c++:UINT(unsigned int) ---- c#:System.UInt16 8 //c++:UINT(unsigned int) ---- c#:System.UInt32 9 //c++:LONG(long) ---- c#:System.Int32 10 //c++:ULONG(unsigned long) ---- c#:System.UInt32 11 //c++:DWORD(unsigned long) ---- c#:System.UInt32 12 //c++:DECIMAL ---- c#:System.Decimal 13 //c++:BOOL(long) ---- c#:System.Boolean 14 //c++:CHAR(char) ---- c#:System.Char 15 //c++:LPSTR(char *) ---- c#:System.String 16 //c++:LPWSTR(wchar_t *) ---- c#:System.String 17 //c++:LPCSTR(const char *) ---- c#:System.String 18 //c++:LPCWSTR(const wchar_t *) ---- c#:System.String 19 //c++:PCAHR(char *) ---- c#:System.String 20 //c++:BSTR ---- c#:System.String 21 //c++:FLOAT(float) ---- c#:System.Single 22 //c++:DOUBLE(double) ---- c#:System.Double 23 //c++:VARIANT ---- c#:System.Object 24 //c++:PBYTE(byte *) ---- c#:System.Byte[] 25 //c++:BSTR ---- c#:StringBuilder 26 //c++:LPCTSTR ---- c#:StringBuilder 27 //c++:LPCTSTR ---- c#:string 28 //c++:LPTSTR ---- c#:[MarshalAs(UnmanagedType.LPTStr)] string 29 //c++:LPTSTR 输出变量名 ---- c#:StringBuilder 输出变量名 30 //c++:LPCWSTR ---- c#:IntPtr 31 //c++:BOOL ---- c#:bool 32 //c++:HMODULE ---- c#:IntPtr 33 //c++:HINSTANCE ---- c#:IntPtr 34 //c++:结构体 ---- c#:public struct 结构体{}; 35 //c++:结构体 **变量名 ---- c#:out 变量名 36 //C#中提前申明一个结构体实例化后的变量名 37 //c++:结构体 &变量名 ---- c#:ref 结构体 变量名 38 //c++:WORD ---- c#:ushort 39 //c++:DWORD ---- c#:uint 40 //c++:DWORD ---- c#:int 41 //c++:UCHAR ---- c#:int 42 //c++:UCHAR ---- c#:byte 43 //c++:UCHAR* ---- c#:string 44 //c++:UCHAR* ---- c#:IntPtr 45 //c++:GUID ---- c#:Guid 46 //c++:Handle ---- c#:IntPtr 47 //c++:HWND ---- c#:IntPtr 48 //c++:DWORD ---- c#:int 49 //c++:COLORREF ---- c#:uint 50 //c++:unsigned char ---- c#:byte 51 //c++:unsigned char * ---- c#:ref byte 52 //c++:unsigned char * ---- c#:[MarshalAs(UnmanagedType.LPArray)] byte[] 53 //c++:unsigned char * ---- c#:[MarshalAs(UnmanagedType.LPArray)] Intptr 54 //c++:unsigned char & ---- c#:ref byte 55 //c++:unsigned char 变量名 ---- c#:byte 变量名 56 //c++:unsigned short 变量名 ---- c#:ushort 变量名 57 //c++:unsigned int 变量名 ---- c#:uint 变量名 58 //c++:unsigned long 变量名 ---- c#:ulong 变量名 59 //c++:char 变量名 ---- c#:byte 变量名 60 //C++中一个字符用一个字节表示,C#中一个字符用两个字节表示 61 //c++:char 数组名[数组大小] ---- c#:MarshalAs(UnmanagedType.ByValTStr, SizeConst = 数组大小)] 62 public string 数组名; ushort 63 //c++:char * ---- c#:string 64 //传入参数 65 //c++:char * ---- c#:StringBuilder 66 //传出参数 67 //c++:char *变量名 ---- c#:ref string 变量名 68 //c++:char *输入变量名 ---- c#:string 输入变量名 69 //c++:char *输出变量名 ---- c#:[MarshalAs(UnmanagedType.LPStr)] StringBuilder 输出变量名 70 //c++:char ** ---- c#:string 71 //c++:char **变量名 ---- c#:ref string 变量名 72 //c++:const char * ---- c#:string 73 //c++:char[] ---- c#:string 74 //c++:char 变量名[数组大小] ---- c#:[MarshalAs(UnmanagedType.ByValTStr,SizeConst=数组大小)] public string 变量名; 75 //c++:struct 结构体名 *变量名 ---- c#:ref 结构体名 变量名 76 //c++:委托 变量名 ---- c#:委托 变量名 77 //c++:int ---- c#:int 78 //c++:int ---- c#:ref int 79 //c++:int & ---- c#:ref int 80 //c++:int * ---- c#:ref int 81 //C#中调用前需定义int 变量名 = 0; 82 //c++:*int ---- c#:IntPtr 83 //c++:int32 PIPTR * ---- c#:int32[] 84 //c++:float PIPTR * ---- c#:float[] 85 //c++:double** 数组名 ---- c#:ref double 数组名 86 //c++:double*[] 数组名 ---- c#:ref double 数组名 87 //c++:long ---- c#:int 88 //c++:ulong ---- c#:int 89 //c++:UINT8 * ---- c#:ref byte 90 //C#中调用前需定义byte 变量名 = new byte(); 91 //c++:handle ---- c#:IntPtr 92 //c++:hwnd ---- c#:IntPtr 93 //c++:void * ---- c#:IntPtr 94 //c++:void * user_obj_param ---- c#:IntPtr user_obj_param 95 //c++:void * 对象名称 ---- c#:([MarshalAs(UnmanagedType.AsAny)]Object 对象名称 96 //c++:char, INT8, SBYTE, CHAR ---- c#:System.SByte 97 //c++:short, short int, INT16, SHORT ---- c#:System.Int16 98 //c++:int, long, long int, INT32, LONG32, BOOL , INT ---- c#:System.Int32 99 //c++:__int64, INT64, LONGLONG ---- c#:System.Int64 100 //c++:unsigned char, UINT8, UCHAR , BYTE ---- c#:System.Byte 101 //c++:unsigned short, UINT16, USHORT, WORD, ATOM, WCHAR , __wchar_t ---- c#:System.UInt16 102 //c++:unsigned, unsigned int, UINT32, ULONG32, DWORD32, ULONG, DWORD, UINT ---- c#:System.UInt32 103 //c++:unsigned __int64, UINT64, DWORDLONG, ULONGLONG ---- c#:System.UInt64 104 //c++:float, FLOAT ---- c#:System.Single 105 //c++:double, long double, DOUBLE ---- c#:System.Double 106 //Win32 Types ---- CLR Type 107 //Struct需要在C#里重新定义一个Struct 108 //CallBack回调函数需要封装在一个委托里,delegate static extern int FunCallBack(string str); 109 //unsigned char** ppImage替换成IntPtr ppImage 110 //int& nWidth替换成ref int nWidth 111 //int*, int&, 则都可用 ref int 对应 112 //双针指类型参数,可以用 ref IntP
c++转C#
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。