Argument passed ByVal to VB.NET Function and manipulated there

前端 未结 2 814
花落未央
花落未央 2021-01-24 02:21

In this Microsoft sample an array Of Doubles is passed to the functions MultiplyMatricesSequential(...) and MultiplyMatricesParallel(...) as argument r

2条回答
  •  孤街浪徒
    2021-01-24 02:54

    When you pass an object ByVal to a function, you put a pointer to it on the stack. Then function can then modify the inner parts of the object, but not replace it with a new object.

    When you pass an object ByRef, you instead put a pointer to the objects pointer on the stack. The function can now replace the entire object with a new one.

    If you send an intrinsic value, like an Int32, to a function ByVal the value is put on the stack and can't be edited at all by the function.

提交回复
热议问题