Share via


OutAttribute Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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

Inheritance Hierarchy

System. . :: . .Object
  System. . :: . .Attribute
    System.Runtime.InteropServices..::..OutAttribute

Namespace:  System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Parameter, Inherited := False)> _
Public NotInheritable Class OutAttribute _
    Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Parameter, Inherited = false)]
public sealed class OutAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Parameter, Inherited = false)]
public ref class OutAttribute sealed : public Attribute
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Parameter, Inherited = false)>]
type OutAttribute =  
    class
        inherit Attribute
    end
public final class OutAttribute extends Attribute

The OutAttribute type exposes the following members.

Constructors

  Name Description
Public method OutAttribute Initializes a new instance of the OutAttribute class.

Top

Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

You can apply this attribute to parameters.

The OutAttribute is optional. The attribute is supported for COM interop and platform invoke only. In the absence of explicit settings, the interop marshaler assumes rules based on the parameter type, whether the parameter is passed by reference or by value, and whether the type is blittable or non-blittable. For example, the StringBuilder class is always assumed to be In/Out and an array of strings passed by value is assumed to be In.

Out-only behavior is never a default marshaling behavior for parameters. You can apply the OutAttribute to value and reference types passed by reference to change In/Out behavior to Out-only behavior, which is equivalent to using the out keyword in C#. For example, arrays passed by value, marshaled as In-only parameters by default, can be changed to Out-only. However, the behavior does not always provide expected semantics when the types include all-blittable elements or fields because the interop marshaler uses pinning. If you do not care about passing data into the callee, Out-only marshaling can provide better performance for non-blittable types.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.Runtime.InteropServices Namespace