C# Passing arguments by default is ByRef instead of ByVal

后端 未结 5 1859
闹比i
闹比i 2020-12-05 07:40

I know the default is ByVal in C#. I used same variable names in many places and then I noticed passed values change and come back. I think I knew scope mechanism of C# wron

5条回答
  •  情深已故
    2020-12-05 08:13

    You need to learn the difference between reference types and value types. Here I presume you are using a reference type License, which means you are actually parsing a reference to the instance in question.

    See: http://msdn.microsoft.com/en-us/library/aa711899(v=vs.71).aspx

    Although, not necessarily correct a value type is often allocated on the stack or within a reference type. While reference types are always allocated on the managed heap.

提交回复
热议问题