c++到c#:有3个元素的字节指针数组等于什么?
C++ to C#: What is equivalent of array of byte pointer with 3 element
我用c++写了这段代码
BYTE * apData[3]
如何将其转换为c# ?(我使用DllImport)
就用byte[]
:
[DllImport EntryPoint="myfunc"]
public extern static void MyFunc(byte[]);
byte[] apData = new byte[3];
MyFunc(apData);
这是一个指向BYTE
的长度为3的数组。
假设this出现在结构体中,它被声明为:
[MarshalAs(UnmanagedType.ByValArray, SizeConst=3)]
IntPtr[] apData;
或者,如果数组作为形参传递,则像这样声明该形参:
[MarshalAs(UnmanagedType.LPArray, SizeConst=3)]
IntPtr[] apData
可以使用原始指针
[System.Runtime.InteropServices.DllImportAttribute("<Unknown>", EntryPoint="fun")]
public static extern void fun(System.IntPtr byte_array) ;
使用如下所示的DLLImport
[DllImport EntryPoint="func"]
public extern static void Func(byte[]);
byte[] apData = new byte[3];
相关文章:
- 通过JNI传递数据数组的最快方法是什么
- 讨论 - 创建矩阵时的数组与向量的向量 - 什么是最实用的选择
- 在 c++ 中对类中的 c 字符串动态数组进行排序的最佳方法是什么?
- 当 std::move 与 C 样式数组或不移动对象时会发生什么
- 当该数组的索引中没有元素时,指针指向什么?
- 在数组中输入 n 个整数的列表,并以类似于钟摆来回移动的方式排列它们. 输入-1 3 2 5 4,输出5 3 1 2 4
- 给定一个整数数组,需要在Max_Heap上运行操作。得到错误"segmentation fault",有什么想法吗?(C++)
- 适用于大型数组的无复制线程安全环形缓冲区
- 为什么std::begin()和std::end()适用于固定数组,而不适用于动态数组
- 将函子应用于设备数组的子集的最有效方法是什么
- VB6 相当于 C++ 个字符数组是什么?
- 这是什么数组声明
- 如何检查字符串值是否存在于字符数组中
- 为什么 strlen() 也适用于字符数组
- 应用于单词数组的随机数范围
- 如果将 delete[] 应用于非数组指针会发生什么情况
- 一个类似于动态数组的C++容器
- 为什么只有非常量映射提供类似于关联数组的直接元素检索?
- 什么数组结构在c#中有,而在C/ c++ /Java中没有
- 数组相对于向量有什么优势?