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

FieldOffsetAttribute コンストラクタ

フィールドの先頭に対する構造体でのオフセットを指定して、FieldOffsetAttribute クラスの新しいインスタンスを初期化します。

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

Dim offset As Integer

Dim instance As New FieldOffsetAttribute(offset)
public FieldOffsetAttribute (
    int offset
)
public:
FieldOffsetAttribute (
    int offset
)
public FieldOffsetAttribute (
    int offset
)
public function FieldOffsetAttribute (
    offset : int
)

パラメータ

offset

構造体の先頭からフィールドの先頭までのバイト単位のオフセット。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FieldOffsetAttribute クラス
FieldOffsetAttribute メンバ
System.Runtime.InteropServices 名前空間

FieldOffsetAttribute プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

FieldOffsetAttribute クラス
System.Runtime.InteropServices 名前空間
StructLayoutAttribute
LayoutKind

FieldOffsetAttribute メソッド


パブリック メソッドパブリック メソッド

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

関連項目

FieldOffsetAttribute クラス
System.Runtime.InteropServices 名前空間
StructLayoutAttribute
LayoutKind

FieldOffsetAttribute メンバ

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

FieldOffsetAttribute データ型で公開されるメンバを以下の表に示します。


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

関連項目

FieldOffsetAttribute クラス
System.Runtime.InteropServices 名前空間
StructLayoutAttribute
LayoutKind



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「FieldOffsetAttribute」の関連用語

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

   

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



FieldOffsetAttributeのページの著作権

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

©2026 GRAS Group, Inc.RSS