从C++到C#获取无符号整型数组可以通过以下步骤实现:
unsigned int arr[] = {1, 2, 3, 4, 5};
int size = sizeof(arr) / sizeof(arr[0]);
array<System::UInt32>^ ConvertToUnsignedIntArray(unsigned int* arr, int size)
{
array<System::UInt32>^ result = gcnew array<System::UInt32>(size);
for (int i = 0; i < size; i++)
{
result[i] = arr[i];
}
return result;
}
unsigned int[] arr = new unsigned int[] { 1, 2, 3, 4, 5 };
int size = arr.Length;
YourCppCliProject.YourClass instance = new YourCppCliProject.YourClass();
uint[] result = instance.ConvertToUnsignedIntArray(arr, size);
这样,你就可以从C++获取无符号整型数组,并在C#中使用了。
领取专属 10元无门槛券
手把手带您无忧上云