Indicates that data should be marshaled from callee back to caller.
For a list of all members of this type, see OutAttribute Members.
[Visual Basic] <AttributeUsage(AttributeTargets.Parameter)> NotInheritable Public Class OutAttribute Inherits Attribute [C#] [AttributeUsage(AttributeTargets.Parameter)] public sealed class OutAttribute : Attribute [C++] [AttributeUsage(AttributeTargets::Parameter)] public __gc __sealed class OutAttribute : public Attribute [JScript] public AttributeUsage(AttributeTargets.Parameter) class OutAttribute extends Attribute
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
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.
Combining the InAttribute and OutAttribute is particularly useful when applied to arrays and formatted, non-blittable types. Callers see the changes a callee makes to these types only when you apply both attributes. Since these types require copying during marshaling, you can use InAttribute and OutAttribute to reduce unnecessary copies.
For more information on the effect of OutAttribute on marshaling behavior, see Directional Attributes.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
Assembly: Mscorlib (in Mscorlib.dll)