我想将以下代码从C#转换为VB .NET。我希望有人有解决方案。
IntPtr[] buffer = new IntPtr[5];
for (Int32 i = 0; i < 5; ++i)
{
buffer[i] = Marshal.AllocHGlobal(100);
}
for (Int32 i = 0; i < 5; ++i)
{
Marshal.FreeHGlobal(buffer[i]);
}
提前致谢!
答案 0 :(得分:3)
Dim buffer As IntPtr() = New IntPtr(4) {}
For i As Int32 = 0 To 4
buffer(i) = Marshal.AllocHGlobal(100)
Next
For i As Int32 = 0 To 4
Marshal.FreeHGlobal(buffer(i))
Next