C#有没有类似C里面的函数malloc()呢?
请问在C#里面怎么为一组数据分配一块内存空间呢,有没有类似C里面的函数malloc()?
[解决办法]
byte[] d = new byte[10];
不过不用free。由系统自动回收。
你要做的就是使用完成后, d=null;
[解决办法]
Marshal.AllocHGlobal Method (Int32)
Allocates memory from the unmanaged memory of the process by using the specified number of bytes.
参考:
http://msdn.microsoft.com/en-us/library/s69bkh17.aspx
[解决办法]