如何建立一个没有初始化为空或0对象的数组?数组、建立一个、初始化、为空

2023-09-03 07:39:06 作者:のが (逃)

byte[] buffer = new byte[500000];

初​​始化缓冲区0值。由于这是一个缓冲区,我不想任何初始化,是否有可能在C#与C?

initializes buffer with 0 values. As it is a buffer, I dont want any initialization, is it possible in C# as in C?

推荐答案

用随机数字填充它,或者使用的DllImport 虚拟从Win32 API的。

Fill it with random numbers or use DllImport and VirtualAlloc from Win32 API.