How to convert array to char* in C++ CLR?

后端 未结 2 1607
暗喜
暗喜 2021-02-06 03:05

In my project, I pass a byte[] from C# to C++ CLR function.

C++ CLR code:

void TestByteArray(array^ byteArray)
{
    ...
}


        
相关标签:
2条回答
  • 2021-02-06 03:36
    void TestByteArray(array<System::Byte>^ byteArray)
    {
        pin_ptr<System::Byte> p = &byteArray[0];
        unsigned char* pby = p;
        char* pch = reinterpret_cast<char*>(pby);
    
        // use it...
    }
    
    0 讨论(0)
  • 2021-02-06 03:51

    You're looking for the Encoding.GetChars() Method

    0 讨论(0)
提交回复
热议问题