<分区>
我想问一下有什么区别
public int Method1([In, Out] byte[] buffer);
和
public int Method2(byte[] buffer);
我遇到了 http://referencesource.microsoft.com/#mscorlib/system/io/stream.cs,739想知道为什么 [In, Out]
在那里?
标签 c# com-interop
<分区>
我想问一下有什么区别
public int Method1([In, Out] byte[] buffer);
和
public int Method2(byte[] buffer);
我遇到了 http://referencesource.microsoft.com/#mscorlib/system/io/stream.cs,739想知道为什么 [In, Out]
在那里?
最佳答案
是的。有区别。
public int Method2(byte[] buffer);
使用隐式 In
:
Indicates that data should be marshaled from the caller to the callee, but not back to the caller.
public int Method2(out byte[] buffer);
使用 Out
:
Indicates that data should be marshaled from callee back to caller.
public int Method2(ref byte[] buffer);
使用 [In, Out]
。关于c# - 在方法中使用 [in, out],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39393949/