更快地填充字节数组的方法 [英] Faster way to fill a byte array

查看:81
本文介绍了更快地填充字节数组的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,


在C#中有更快的方法吗:


byte []缓冲区;

buffer = new byte [43];


for(int i = 0; i< buffer.Length; i ++)

buffer [i ] = 0;

Dave

All,

Is there a faster way to do this in C#:

byte[] buffer;
buffer = new byte[43];

for(int i = 0; i < buffer.Length; i++)
buffer[i] = 0;
Dave

推荐答案

D.耶茨< fo **** @ hotmail.com>写道:
D. Yates <fo****@hotmail.com> wrote:
全部,

在C#中有更快的方法吗:

byte [] buffer;
buffer =新字节[43];

for(int i = 0; i< buffer.Length; i ++)
buffer [i] = 0;
All,

Is there a faster way to do this in C#:

byte[] buffer;
buffer = new byte[43];

for(int i = 0; i < buffer.Length; i++)
buffer[i] = 0;




是:


byte [] buffer = new byte [43];


保证一开始就是零。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet 博客: http://www.msmvps.com/jon.skeet

如果回复小组,请不要给我发邮件



Yes:

byte[] buffer = new byte[43];

It''s guaranteed to be all zeroes to start with.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


戴夫,


是的:


byte [] buffer;

buffer = new byte [43];


默认情况下,结构数组的元素与那些相同

结构,位为零ut,这正是你想要的。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


D。耶茨" < FO **** @ hotmail.com>在消息中写道

news:e
Dave,

Yes:

byte[] buffer;
buffer = new byte[43];

By default, elements of arrays of structures are the same as those
structures with the bits zeroed out, which is exactly what you want.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"D. Yates" <fo****@hotmail.com> wrote in message
news:e


************** @ TK2MSFTNGP14.phx.gbl ...
**************@TK2MSFTNGP14.phx.gbl...
全部,

在C#中有更快的方法吗:

byte [] buffer;
buffer = new byte [43 ];

for(int i = 0; i< buffer.Length; i ++)
buffer [i] = 0;

Dave
All,

Is there a faster way to do this in C#:

byte[] buffer;
buffer = new byte[43];

for(int i = 0; i < buffer.Length; i++)
buffer[i] = 0;
Dave



这篇关于更快地填充字节数组的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆