This documentation is archived and is not being maintained.

InAttribute Class

Indicates that data should be marshaled from the caller to the callee, but not back to the caller.

For a list of all members of this type, see InAttribute Members.


[Visual Basic]
NotInheritable Public Class InAttribute
   Inherits Attribute
public sealed class InAttribute : Attribute
public __gc __sealed class InAttribute : public Attribute
class InAttribute extends Attribute

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.


You can apply this attribute to parameters.

The InAttribute 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.

You cannot apply the InAttribute to a parameter modified with the C#-styled out keyword. To avoid confusing the In keyword in Visual Basic with the InAttribute, minus Attribute, use the <[In]> form with brackets around the attribute.

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 InAttribute on marshaling behavior, see Directional Attributes.


Namespace: System.Runtime.InteropServices

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)

See Also

InAttribute Members | System.Runtime.InteropServices Namespace | OutAttribute | StringBuilder | Blittable and Non-Blittable Types