Share via


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

설명

이 특성을 필드에 적용할 수 있습니다.

해당 생성자로 전달된 LayoutKind.Explicit와 함께 System.Runtime.InteropServices.StructLayoutAttribute를 클래스 또는 구조체에 적용하여 해당 클래스나 구조체의 관리되지 않는 표현 내에서 static이 아닌 멤버 또는 상수 멤버의 오프셋을 지정하는 경우 이 특성이 사용됩니다.

예제

다음 예제에서는 explicit 레이아웃을 사용하여 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) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0에서 지원

참고 항목

참조

FieldOffsetAttribute 멤버
System.Runtime.InteropServices 네임스페이스
StructLayoutAttribute
LayoutKind