zoukankan      html  css  js  c++  java
  • C++和C#数据类型转换(常用)

    C++ C#
    HANDLE(void *) System.IntPtr
    Byte(unsigned char) System.Byte
    SHORT(short) System.Int16
    WORD(unsigned short) System.Int16
    INT(int) System.Int16 System.Int32
    UINT(unsigned int) System.Int16 System.Int32
    LONG(long) System.Int32
    ULONG(unsigned long) System.UInt32
    CHAR(char) System.Char
    BOOL bool
    LPSTR System.string
    LPWSTR System.string
    LPCSTR System.string
    LPCWSTR System.string
       
    结构体 public struct 结构体{}
    结构体 **变量名 out 变量名
    结构体 &变量名 ref 变量名
    C++ C#
    UCHAR int
    UCHAR byte
    UCHAR* string
    UCHAR* IntPtr
    Handle IntPtr
    COLORREF uint
    unsigned char byte
    unsigned char* ref byte
     

    [MarshalAs(UnmanagedType.LpArray)] byte[]

     

    [MarshalAs(UnmanagedType.LpArray)] IntPtr

    unsigned char& ref byte
    unsigned char变量名 byte 变量名
    unsigned short变量名 short 变量名
    unsigned int变量名 uint 变量名
    unsigned long变量名 ulong 变量名
    unsigned char变量名 byte 变量名
    C++ C#
    char 数组名[数组大小]

    [MarshalAs(UnmanagedType.ByValTStr,SizeConst=数组大小)]

    public string 数组名

       
       
    char* string
    cons char* string 
    char[] string
       
    传入参数  
    char & stringBuilder
    传出参数  
    char * ref string
       
    handle IntPtr
    hwnd IntPtr
    void* IntPtr
  • 相关阅读:
    Storm
    Linux 网络配置
    .NET Remoting
    jwt
    new操作符
    元数据
    C# lock
    三十而立
    面试
    灯火
  • 原文地址:https://www.cnblogs.com/DannyShi/p/4604819.html
Copyright © 2011-2022 走看看