Parameter in C#

前端 未结 4 512
后悔当初
后悔当初 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-26 09:38

    If you look at the function definition on MSDN it will tell you whether the parameters are In/Out:

    BOOL WINAPI GlobalMemoryStatusEx(
      __inout  LPMEMORYSTATUSEX lpBuffer
    );
    

    In general if it says out, you should use a ref parameter, it makes is easier on any future developers trying to figure out how the code is working. When looking at the function call, you know the developer meant for the argument to be affected.

提交回复
热议问题