在方法中使用 [in, out]
Usage of [in, out] in methods
我想问一下
有什么区别吗
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]
.
我想问一下
有什么区别吗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]
.