OutAttribute クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<ComVisibleAttribute(True)> _ <AttributeUsageAttribute(AttributeTargets.Parameter, Inherited:=False)> _ Public NotInheritable Class OutAttribute Inherits Attribute
[ComVisibleAttribute(true)] [AttributeUsageAttribute(AttributeTargets.Parameter, Inherited=false)] public sealed class OutAttribute : Attribute
[ComVisibleAttribute(true)] [AttributeUsageAttribute(AttributeTargets::Parameter, Inherited=false)] public ref class OutAttribute sealed : public Attribute

OutAttribute はオプションです。この属性は、COM 相互運用、およびプラットフォーム呼び出しのときにだけ使用できます。明示的な設定がない場合、相互運用マーシャラは、パラメータの型 (パラメータが参照渡しか値渡しか、型が blittable か非 blittable か) に応じて規則を判断します。たとえば、StringBuilder クラスは常に In/Out として扱われ、値渡しされた文字列の配列は In として扱われます。
Out のみの動作がパラメータの既定のマーシャリング動作となることはありません。参照渡しの値型または参照型に OutAttribute を適用することによって、In/Out の動作を Out のみの動作に変更できます。これは、C# で out キーワードを使用することに相当します。たとえば、値渡しの配列 (既定で In のみのパラメータとしてマーシャリングされる) は、Out のみに変更できます。ただし、相互運用マーシャラは固定を使用するため、要素またはフィールドがすべて blittable の型の場合、この動作は期待されるセマンティクスを提供しないことがあります。データを呼び出し先に渡すかどうかが問題にならない場合、非 blittable 型については Out のみのマーシャリングの方がパフォーマンスに優れています。
InAttribute と OutAttribute を組み合わせると、配列型および書式付きの非 blittable 型に適用する場合に、特に役立ちます。両方の属性を適用した場合にのみ、呼び出し元は、呼び出し先がこれらの型に対して加えた変更を参照できます。これらの型はマーシャリング中にコピーを要求するため、InAttribute と OutAttribute を使用して、不要なコピーを減らすことができます。

パラメータとして配列を渡すプラットフォーム呼び出しのプロトタイプに InAttribute と OutAttribute を適用する例を次に示します。方向属性の組み合わせを使用すると、呼び出し元は呼び出し先によって加えられた変更を確認できます。
' Declare a class member for each structure element. < StructLayout( LayoutKind.Sequential, CharSet:=CharSet.Auto )> _ Public Class OpenFileName Public structSize As Integer = 0 Public filter As String = Nothing Public file As String = Nothing ' ... End Class 'OpenFileName Public Class LibWrap ' Declare managed prototype for the unmanaged function. Declare Auto Function GetOpenFileName Lib "Comdlg32.dll" ( _ <[In], Out> ByVal ofn As OpenFileName ) As Boolean End Class 'LibWrap
// Declare a class member for each structure element. [ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Auto )] public class OpenFileName { public int structSize = 0; public string filter = null; public string file = null; // ... } public class LibWrap { // Declare a managed prototype for the unmanaged function. [ DllImport( "Comdlg32.dll", CharSet=CharSet.Auto )] public static extern bool GetOpenFileName([ In, Out ] OpenFileName ofn ); }
// Declare a class member for each structure element. [StructLayout(LayoutKind::Sequential,CharSet=CharSet::Auto)] public ref class OpenFileName { public: int structSize; String^ filter; String^ file; // ... }; public ref class LibWrap { public: // Declare a managed prototype for the unmanaged function. [DllImport("Comdlg32.dll",CharSet=CharSet::Auto)] static bool GetOpenFileName( [In,Out]OpenFileName^ ofn ); };
// Declare a class member for each structure element. /** @attribute StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto) */ public class OpenFileName { public int structSize = 0; public String filter = null; public String file = null; // ... } //OpenFileName public class LibWrap { // Declare a managed prototype for the unmanaged function. /** @attribute DllImport("Comdlg32.dll", CharSet = CharSet.Auto) */ public static native boolean GetOpenFileName( /** @attribute In() @attribute Out() */ OpenFileName ofn); } //LibWrap

System.Attribute
System.Runtime.InteropServices.OutAttribute


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


OutAttribute コンストラクタ
アセンブリ: mscorlib (mscorlib.dll 内)


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


OutAttribute プロパティ
OutAttribute メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 ( Attribute から継承されます。) |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。) |
![]() | GetHashCode | このインスタンスのハッシュ コードを返します。 ( Attribute から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

OutAttribute メンバ
呼び出し先から呼び出し元へ、データをマーシャリングすることを示します。
OutAttribute データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 ( Attribute から継承されます。) |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。) |
![]() | GetHashCode | このインスタンスのハッシュ コードを返します。 (Attribute から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

- OutAttributeのページへのリンク