Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

I declare a Byte-Array like this:

Byte[] 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?

like image 520
chessweb Avatar asked Jul 14 '11 18:07

chessweb


1 Answers

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.

like image 93
Marc Gravell Avatar answered Nov 17 '22 00:11

Marc Gravell