InAttribute クラス
アセンブリ: mscorlib (mscorlib.dll 内)
構文
<AttributeUsageAttribute(AttributeTargets.Parameter, Inherited:=False)> _ <ComVisibleAttribute(True)> _ Public NotInheritable Class InAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Parameter, Inherited=false)] [ComVisibleAttribute(true)] public sealed class InAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Parameter, Inherited=false)] [ComVisibleAttribute(true)] public ref class InAttribute sealed : public Attribute
InAttribute はオプションです。この属性は、COM 相互運用、およびプラットフォーム呼び出しのときにだけ使用できます。明示的な設定がない場合、相互運用マーシャラは、パラメータの型 (パラメータが参照渡しか値渡しか、型が blittable か非 blittable か) に応じて規則を判断します。たとえば、StringBuilder クラスは常に In/Out として扱われ、値渡しされた文字列の配列は In として扱われます。
C# スタイルの out キーワードで修飾されたパラメータに InAttribute を適用することはできません。Visual Basic の In キーワードと、InAttribute から Attribute が取り除かれた場合を区別するために、属性の前後には <[In]> のようにかっこを付けてください。
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.InAttribute
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
InAttribute コンストラクタ
アセンブリ: 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
InAttribute プロパティ
InAttribute メソッド
パブリック メソッド
名前 | 説明 | |
---|---|---|
Equals | オーバーロードされます。 ( Attribute から継承されます。) | |
GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。) | |
GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。) | |
GetHashCode | このインスタンスのハッシュ コードを返します。 ( Attribute から継承されます。) | |
GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) | |
IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。) | |
IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。) | |
Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。) | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) | |
ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |
InAttribute メンバ
呼び出し元から呼び出し先へデータをマーシャリングするが、逆方向にはマーシャリングしないことを示します。
InAttribute データ型で公開されるメンバを以下の表に示します。
パブリック コンストラクタ
パブリック プロパティ
パブリック メソッド
名前 | 説明 | |
---|---|---|
Equals | オーバーロードされます。 ( Attribute から継承されます。) | |
GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。) | |
GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。) | |
GetHashCode | このインスタンスのハッシュ コードを返します。 (Attribute から継承されます。) | |
GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) | |
IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。) | |
IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。) | |
Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。) | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) | |
ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |
- InAttributeのページへのリンク