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

FieldOffsetAttribute クラス

クラスまたは構造体のアンマネージ表現内にあるフィールド物理的な位置示します

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<ComVisibleAttribute(True)> _
<AttributeUsageAttribute(AttributeTargets.Field, Inherited:=False)> _
Public NotInheritable Class
 FieldOffsetAttribute
    Inherits Attribute
Dim instance As FieldOffsetAttribute
[ComVisibleAttribute(true)] 
[AttributeUsageAttribute(AttributeTargets.Field, Inherited=false)]
 
public sealed class FieldOffsetAttribute :
 Attribute
[ComVisibleAttribute(true)] 
[AttributeUsageAttribute(AttributeTargets::Field, Inherited=false)]
 
public ref class FieldOffsetAttribute sealed
 : public Attribute
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Field, Inherited=false)
 */ 
public final class FieldOffsetAttribute extends
 Attribute
ComVisibleAttribute(true) 
AttributeUsageAttribute(AttributeTargets.Field, Inherited=false)
 
public final class FieldOffsetAttribute extends
 Attribute
解説解説

この属性は、フィールド適用できます

この属性は、System.Runtime.InteropServices.StructLayoutAttribute の LayoutKind.Explicit がコンストラクタ渡されたときに使用されクラスまたは構造体適用して、そのクラスまたは構造体のアンマネージ表現内の各非 static メンバまたは定数メンバオフセット指定します

使用例使用例

明示的なレイアウトを持つクラスメンバFieldOffsetAttribute適用する方法次の例に示します

<StructLayout(LayoutKind.Explicit)> _
Public Class SYSTEM_INFO
    <FieldOffset(0)> Private OemId As
 System.UInt64
    <FieldOffset(4)> Private PageSize As
 System.UInt64
    <FieldOffset(16)> Private ActiveProcessorMask As
 System.UInt64
    <FieldOffset(20)> Private NumberOfProcessors As
 System.UInt64
    <FieldOffset(24)> Private ProcessorType As
 System.UInt64
End Class
[StructLayout(LayoutKind.Explicit)]
public class SYSTEM_INFO
{
[FieldOffset(0)] public ulong OemId;
[FieldOffset(4)] public ulong PageSize;
[FieldOffset(16)] public ulong ActiveProcessorMask;
[FieldOffset(20)] public ulong NumberOfProcessors;
[FieldOffset(24)] public ulong ProcessorType;
}
[StructLayout(LayoutKind::Explicit)]
public ref class SYSTEM_INFO
{
public:

   [FieldOffset(0)]
   UInt64 OemId;

   [FieldOffset(4)]
   UInt64 PageSize;

   [FieldOffset(16)]
   UInt64 ActiveProcessorMask;

   [FieldOffset(20)]
   UInt64 NumberOfProcessors;

   [FieldOffset(24)]
   UInt64 ProcessorType;
};

/** @attribute StructLayout(LayoutKind.Explicit)
 */
public class SYSTEM_INFO
{   
    /** @attribute FieldOffset(0)
     */
    public long oemId;
    
    /** @attribute FieldOffset(4)
     */
    public long pageSize;
    
    /** @attribute FieldOffset(16)
     */
    public long activeProcessorMask;
   
    /** @attribute FieldOffset(20)
     */
    public long numberOfProcessors;
    
    /** @attribute FieldOffset(24)
     */
    public long processorType;
   
} //SYSTEM_INFO
継承階層継承階層
System.Object
   System.Attribute
    System.Runtime.InteropServices.FieldOffsetAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FieldOffsetAttribute メンバ
System.Runtime.InteropServices 名前空間
StructLayoutAttribute
LayoutKind


このページでは「.NET Framework クラス ライブラリ リファレンス」からFieldOffsetAttribute クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からFieldOffsetAttribute クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からFieldOffsetAttribute クラス を検索

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

辞書ショートカット

すべての辞書の索引

「FieldOffsetAttribute クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS