开发者

C#: Why doesn't Initialize work with a Byte-Array?

开发者 https://www.devze.com 2023-03-20 14:56 出处:网络
I declare a Byte-Array like this: By开发者_如何学Pythonte[] b = new Byte[10]; and assign some values:

I declare a Byte-Array like this:

By开发者_如何学Pythonte[] b = new Byte[10];

and assign some values:

for (int i=0; i<b.Length; i++)
{
    b[i] = 1;
}

Now I want to zero the array again and call:

b.Initialize(); 

which doesn't work. The array remains unchanged. Isn't b a value-type array?


See MSDN:

Caution

You can use this method only on value types that have constructors; however, value types that are native to C# do not have constructors.

byte is native.

0

精彩评论

暂无评论...
验证码 换一张
取 消