简体   繁体   中英

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

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 ba 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM