Parameter in C#

前端 未结 4 510
后悔当初
后悔当初 2021-01-26 09:15

When I want get total value of memory in C# I found a kernel32 function in MSDN to invoke data from system. MSDN declare function this way:

[return: MarshalAs(Un         


        
4条回答
  •  迷失自我
    2021-01-26 09:49

    The out and the ref parameters are used to return values in the same variables, ref is enough if you don't know you will use it in or out.

    Out if you just want to use the variable to receive data from the function, In if you just want to send data to the function.

    ref if you want to send and receive data from a function, if you put nothing so it will be In by default

    Note: ref and out parameters are very useful when your method needs to return more than one values.

提交回复
热议问题