Hung Manh Tran Hung Manh Tran - 1 year ago 77
C# Question

Usage of [in, out] in methods

I want to ask if there is some difference between

public int Method1([In, Out] byte[] buffer);


public int Method2(byte[] buffer);

I came across,739 and wonder why
[In, Out]
is there?

Answer Source

Yes. There are differences.

  • public int Method2(byte[] buffer); uses implicit 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); uses Out:

    Indicates that data should be marshaled from callee back to caller.

  • public int Method2(ref byte[] buffer); uses [In, Out].
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download