C # Corresponds to the Data Type table in C ++

Source: Internet
Author: User

The prototype of the DLL function in/C ++ is
// Extern "C" _ declspec (dllexport) bool method name 1 (const char * variable name 1, unsigned char * variable name 2)
// Extern "C" _ declspec (dllexport) bool method name 2 (const unsigned char * variable name 1, char * variable name 2)

// C # Call all data type conversion methods collected and sorted by C ++ DLL. There may be repeated or multiple solutions, and you can test them more by yourself.
// C ++: handle (void *) ---- C #: system. intptr
// C ++: byte (unsigned char) ---- C #: system. byte
// C ++: Short (short) ---- C #: system. int16
// C ++: Word (unsigned short) ---- C #: system. uint16
// C ++: int (INT) ---- C #: system. int16
// C ++: int (INT) ---- C #: system. int32
// C ++: uint (unsigned INT) ---- C #: system. uint16
// C ++: uint (unsigned INT) ---- C #: system. uint32
// C ++: Long (long) ---- C #: system. int32
// C ++: ulong (unsigned long) ---- C #: system. uint32
// C ++: DWORD (unsigned long) ---- C #: system. uint32
// C ++: decimal ---- C #: system. Decimal
// C ++: bool (long) ---- C #: system. Boolean
// C ++: Char (char) ---- C #: system. Char
// C ++: lpstr (char *) ---- C #: system. String
// C ++: lpwstr (wchar_t *) ---- C #: system. String
// C ++: lpcstr (const char *) ---- C #: system. String
// C ++: lpcwstr (const wchar_t *) ---- C #: system. String
// C ++: pcahr (char *) ---- C #: system. String
// C ++: BSTR ---- C #: system. String
// C ++: Float (float) ---- C #: system. Single
// C ++: Double (double) ---- C #: system. Double
// C ++: variant ---- C #: system. Object
// C ++: pbyte (byte *) ---- C #: system. byte []

// C ++: BSTR ---- C #: stringbuilder
// C ++: lpctstr ---- C #: stringbuilder
// C ++: lpctstr ---- C #: String
// C ++: lptstr ---- C #: [financialas (unmanagedtype. lptstr)] string
// C ++: lptstr output variable name ---- C #: stringbuilder output variable name
// C ++: lpcwstr ---- C #: intptr
// C ++: bool ---- C #: bool
// C ++: hmodule ---- C #: intptr
// C ++: hinstance ---- C #: intptr
// C ++: struct ---- C #: public struct {};
// C ++: struct ** variable name ---- C #: Out variable name // C # declare the variable name after the struct is instantiated in advance
// C ++: struct & variable name ---- C #: ref struct variable name

// C ++: Word ---- C #: ushort
// C ++: DWORD ---- C #: uint
// C ++: DWORD ---- C #: int

// C ++: uchar ---- C #: int
// C ++: uchar ---- C #: byte
// C ++: uchar * ---- C #: String
// C ++: uchar * ---- C #: intptr

// C ++: guid ---- C #: guid
// C ++: handle ---- C #: intptr
// C ++: hwnd ---- C #: intptr
// C ++: DWORD ---- C #: int
// C ++: colorref ---- C #: uint

// C ++: unsigned char ---- C #: byte
// C ++: unsigned char * ---- C #: ref byte
// C ++: unsigned char * ---- C #: [financialas (unmanagedtype. lparray)] Byte []
// C ++: unsigned char * ---- C #: [financialas (unmanagedtype. lparray)] intptr

// C ++: unsigned char & ---- C #: ref byte
// C ++: unsigned char variable name ---- C #: Byte variable name
// C ++: Unsigned short variable name ---- C #: ushort variable name
// C ++: Unsigned int variable name ---- C #: uint variable name
// C ++: Unsigned long variable name ---- C #: ulong variable name

// C ++: Char variable name ---- C #: Byte variable name // one character in C ++ is represented by one byte, and one character in C # is represented by two bytes.
// C ++: char array name [array size] ---- C #: financialas (unmanagedtype. byvaltstr, sizeconst = array size)] Public String Array name; ushort

// C ++: char * ---- C #: String // input parameters
// C ++: char * ---- C #: stringbuilder // output parameters
// C ++: char * variable name ---- C #: ref string variable name
// C ++: char * input variable name ---- C #: String input variable name
// C ++: char * output variable name ---- C #: [marshalas (unmanagedtype. lpstr)] stringbuilder output variable name

// C ++: Char ** ---- C #: String
// C ++: Char ** variable name ---- C #: ref string variable name
// C ++: const char * ---- C #: String
// C ++: Char [] ---- C #: String
// C ++: Char variable name [array size] ---- C #: [financialas (unmanagedtype. byvaltstr, sizeconst = array size)] public string variable name;

// C ++: struct name * variable name ---- C #: ref struct name variable name
// C ++: Delegate variable name ---- C #: Delegate variable name

// C ++: int ---- C #: int
// C ++: int ---- C #: ref int
// C ++: Int & ---- C #: ref int
// C ++: int * ---- C #: ref int // C # The Int variable name = 0 must be defined before the call;

// C ++: * int ---- C #: intptr
// C ++: int32 piptr * ---- C #: int32 []
// C ++: Float piptr * ---- C #: float []

// C ++: Double ** array name ---- C #: ref double array name
// C ++: Double * [] array name ---- C #: ref double array name
// C ++: Long ---- C #: int
// C ++: ulong ---- C #: int

// C ++: uint8 * ---- C #: ref byte // The Byte variable name = new byte () needs to be defined before calling in Ref byte // C ();

// C ++: handle ---- C #: intptr
// C ++: hwnd ---- C #: intptr


// C ++: void * ---- C #: intptr
// C ++: void * user_obj_param ---- C #: intptr user_obj_param
// C ++: void * Object Name ---- C # :( [externalas (unmanagedtype. asany)] object Object Name


// C ++: Char, int8, sbyte, char ---- C #: system. sbyte
// C ++: short, short int, int16, short ---- C #: system. int16
// C ++: int, long, long int, int32, long32, bool, int ---- C #: system. int32
// C ++ :__ int64, int64, Longlong ---- C #: system. int64
// C ++: unsigned char, uint8, uchar, byte ---- C #: system. byte
// C ++: Unsigned short, uint16, ushort, word, Atom, wchar, _ wchar_t ---- C #: system. uint16
// C ++: unsigned, unsigned int, uint32, ulong32, dword32, ulong, DWORD, uint ---- C #: system. uint32
// C ++: Unsigned _ int64, uint64, dwordlong, ulonglong ---- C #: system. uint64
// C ++: float, float ---- C #: system. Single
// C ++: Double, Long Double, double ---- C #: system. Double

// Win32 types ---- CLR type

// Struct needs to be redefined in C #
// The callback function needs to be encapsulated in a delegate, delegate static extern int funcallback (string Str );

// Unsigned char ** replace ppimage with intptr ppimage
// Replace Int & nwidth with ref int nwidth
// Int *, Int &, corresponding to ref int
// Double-Pin Type parameter. You can use ref intptr
// The function pointer uses C ++: typedef double (* fun_type1) (double); corresponding to C #: Public Delegate double fun_type1 (double );
// Char * operation C ++: char *; corresponding to C #: stringbuilder;
// Use Pointer in C #: Add unsafe where the pointer is needed

// Unsigned char corresponds to public byte
/*
* Typedef void (* callbackfun1w) (wchar_t *, void * parg );
* Typedef void (* callbackfun1a) (char *, void * parg );
* Bool bioprint_sensor_api dllfun1 (callbackfun1 pcallbackfun1, void * parg );
* The call method is
* [Unmanagedfunctionpointer (callingconvention. cdecl)]
* Public Delegate void callbackfunc1 ([financialas (unmanagedtype. lpwstr)] stringbuilder strname, intptr parg );
*
*
*/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.