In C# what is the default value of the bytes when creating a new byte array?

后端 未结 3 1884
既然无缘
既然无缘 2021-01-18 04:50

The answer to this question has eluded my search.

When I do this:

  var authToken = new byte[16]; 

What is the value of authToken[0

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-18 04:55

    From Arrays (C# Programming Guide)

    The default values of numeric array elements are set to zero, and reference elements are set to null.

    Since byte represents integer values from 0 to 255, all elements are set to 0 in your authToken array.

提交回复
热议问题