关于C++到C#的数据类型转换,该怎么处理

关于C++到C#的数据类型转换
本帖最后由 u014247189 于 2014-05-31 13:04:03 编辑
一个C++的函数原型是这样的
int __stdcall GuestCard(uchar d12,int dlsCoID,uchar CardNo,uchar dai,
uchar LLock,uchar pdoors,uchar BDate[10],
uchar EDate[10],uchar LockNo[8],uchar *cardHexStr)


在C#程序中调用的时候 里边的 uchar BDate[10],这种数组在C#里边要用什么类型?
------解决方案--------------------
char[] BDate= new char[10];
------解决方案--------------------
How to use unsigned char in C#?
引用
There is no such data type "unsigned char" in C#. You probably want to use the "byte" data type. There is also ushort (16-bit), uint (32-bit), and ulong (64-bit). In C/C++ an unsigned char is just a byte, so use the "byte" data type. Here is a list of built in data types in C#: Built-In Types Table (C# Reference)


C#调用C++的DLL 所有数据类型转换方式
引用
UCHAR=>int/byte (大部分情况都可以使用int代替,而如果需要严格对齐的话则应该用byte)

------解决方案--------------------

int __stdcall GuestCard(uchar d12,int dlsCoID,uchar CardNo,uchar dai,
uchar LLock,uchar pdoors,uchar BDate[10],
uchar EDate[10],uchar LockNo[8],uchar *cardHexStr);


static extern GuestCard(byte d12, int dlsCoID, byte CardNo,  
byte LLock, byte pdoors, byte [] BDate, 
byte EDate[10], byte LockNo[8], IntPtr cardHexStr);
 

------解决方案--------------------
引用:

int __stdcall GuestCard(uchar d12,int dlsCoID,uchar CardNo,uchar dai,
uchar LLock,uchar pdoors,uchar BDate[10],
uchar EDate[10],uchar LockNo[8],uchar *cardHexStr);


static extern GuestCard(byte d12, int dlsCoID, byte CardNo,  
byte LLock, byte pdoors, byte [] BDate, 
byte EDate[10], byte LockNo[8], IntPtr cardHexStr);
 


注释:_in C++,uchar be unsigned char is byte