sách gpt4 ăn đã đi

c# - 在 C# 中分配 "unmanaged"内存

In lại 作者:IT王子 更新时间:2023-10-28 23:29:28 25 4
mua khóa gpt4 giày nike

我正在用 C# 编写一个使用 C++ 库的程序,出于某种原因,我需要分配一个非托管缓冲区以将其传递给库。有没有办法在 c# 中做到这一点?基本上我只需要在 C# 中做一个 malloc...

Cảm ơn

câu trả lời hay nhất

Hãy thử điều này:

sử dụng Hệ thống;
using System.Runtime.InteropServices;

class Example
{
static void Main()
{
IntPtr pointer = Marshal.AllocHGlobal(1024);
}
}

这使用 Marshal.AllocHGlobalphương pháp:

Allocates memory from the unmanaged memory of the process by using the specified number of bytes.

关于c# - 在 C# 中分配 "unmanaged"内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2648560/

25 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress