InAttribute クラス

呼び出し元から呼び出し先へデータをマーシャリングするが、逆方向にはマーシャリングしないことを示します。

この型のすべてのメンバの一覧については、InAttribute メンバ を参照してください。

System.Object
   System.Attribute
      System.Runtime.InteropServices.InAttribute

<AttributeUsage(AttributeTargets.Parameter)>
NotInheritable Public Class InAttribute   Inherits Attribute
[C#]
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class InAttribute : Attribute
[C++]
[AttributeUsage(AttributeTargets::Parameter)]
public __gc __sealed class InAttribute : public Attribute
[JScript]
public
   AttributeUsage(AttributeTargets.Parameter)
class InAttribute extends Attribute

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

この属性は、パラメータに適用できます。

InAttribute はオプションです。この属性は、COM 相互運用、およびプラットフォーム呼び出しのときにだけ使用できます。明示的な設定がない場合、相互運用マーシャラは、パラメータの型 (パラメータが参照渡しか値渡しか、型が blittable か非 blittable か) に応じて規則を判断します。たとえば、 StringBuilder クラスは常に In/Out として扱われ、値渡しされた文字列の配列は入力として In 扱われます。

C# スタイルの out キーワードで修飾されたパラメータに InAttribute を適用することはできません。Visual Basic の In キーワードと、 InAttribute から Attribute が取り除かれた場合を区別するために、属性の前後には <[In]> のようにかっこを付けてください。

InAttributeOutAttribute を組み合わせると、配列、および書式付きの非 blittable 型に適用する場合に、特に役立ちます。両方の属性を適用した場合にだけ、呼び出し元は、呼び出し先がこれらの型に対して加えた変更を参照できます。これらの型はマーシャリング中にコピーを要求するため、 InAttributeOutAttribute を使用して、不要なコピーを減らすことができます。

マーシャリングの動作に InAttribute が与える影響の詳細については、「 方向属性 」を参照してください。

必要条件

名前空間: System.Runtime.InteropServices

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

アセンブリ: Mscorlib (Mscorlib.dll 内)

参照

InAttribute メンバ | System.Runtime.InteropServices 名前空間 | OutAttribute | StringBuilder | Blittable 型と非 Blittable 型