What kind of memory semantics govern array assignment in c#?

后端 未结 7 1146
长情又很酷
长情又很酷 2021-01-19 04:12

Given the following: byte[] sData; and a function declared as private byte[] construct_command()

if I were to then assign the resul

7条回答
  •  日久生厌
    2021-01-19 04:23

    Assuming sData is a local variable, it will live in the stack and it will refer to the array returned by the method. The method does not return the contents of the array itself, but a reference to the array.

    In .net, arrays are first class objects and all array-type variables are in fact references.

提交回复
热议问题