Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
OutAttribute クラスとは何? わかりやすく解説 Weblio辞書
[go: Go Back, main page]

OutAttribute クラスとは? わかりやすく解説

OutAttribute クラス

呼び出し先から呼び出し元へデータマーシャリングすることを示します

名前空間: System.Runtime.InteropServices
アセンブリ: 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
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Parameter, Inherited=false)
 */ 
public final class OutAttribute extends Attribute
ComVisibleAttribute(true) 
AttributeUsageAttribute(AttributeTargets.Parameter, Inherited=false)
 
public final class OutAttribute extends
 Attribute
解説解説

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

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

Out のみの動作パラメータ既定マーシャリング動作となることはありません。参照渡し値型または参照型OutAttribute適用することによって、In/Out動作Out のみの動作変更できます。これは、C#out キーワードを使用することに相当します。たとえば、値渡し配列 (既定で In のみのパラメータとしてマーシャリングされる) は、Out のみに変更できます。ただし、相互運用マーシャラは固定使用するため、要素またはフィールドがすべて blittable の型の場合、この動作期待されるセマンティクス提供しないことがありますデータ呼び出し先に渡すかどうか問題にならない場合、非 blittable 型については Out のみのマーシャリングの方がパフォーマンス優れてます。

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

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

使用例使用例

パラメータとして配列を渡すプラットフォーム呼び出しプロトタイプInAttributeOutAttribute適用する例を次に示します方向属性組み合わせ使用すると、呼び出し元は呼び出し先によって加えられ変更確認できます

' 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.Object
   System.Attribute
    System.Runtime.InteropServices.OutAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
OutAttribute メンバ
System.Runtime.InteropServices 名前空間
InAttribute クラス
StringBuilder
その他の技術情報
Blittable 型と非 Blittable 型



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「OutAttribute クラス」の関連用語

OutAttribute クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



OutAttribute クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS