다음을 통해 공유


AttributeTargets 열거형

특성을 지정할 수 있는 응용 프로그램 요소를 지정합니다.

이 열거형에는 멤버 값를 비트로 조합할 수 있는 FlagsAttribute 특성이 있습니다.

네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
<FlagsAttribute> _
Public Enumeration AttributeTargets
‘사용 방법
Dim instance As AttributeTargets
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
[FlagsAttribute] 
public enum AttributeTargets
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
[FlagsAttribute] 
public enum class AttributeTargets
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute FlagsAttribute() */ 
public enum AttributeTargets
SerializableAttribute 
ComVisibleAttribute(true) 
FlagsAttribute 
public enum AttributeTargets

멤버

  멤버 이름 설명
Supported by the .NET Compact Framework All 특성은 모든 응용 프로그램 요소에 적용할 수 있습니다. 
Supported by the .NET Compact Framework Assembly 특성은 어셈블리에 적용할 수 있습니다. 
Supported by the .NET Compact Framework Class 특성은 클래스에 적용할 수 있습니다. 
Supported by the .NET Compact Framework Constructor 특성은 생성자에 적용할 수 있습니다. 
Supported by the .NET Compact Framework Delegate 특성은 대리자에 적용할 수 있습니다. 
Supported by the .NET Compact Framework Enum 특성은 열거형에 적용할 수 있습니다. 
Supported by the .NET Compact Framework Event 특성은 이벤트에 적용할 수 있습니다. 
Supported by the .NET Compact Framework Field 특성은 필드에 적용할 수 있습니다. 
Supported by the .NET Compact Framework GenericParameter 특성은 제네릭 매개 변수에 적용할 수 있습니다. 
Supported by the .NET Compact Framework Interface 특성은 인터페이스에 적용할 수 있습니다. 
Supported by the .NET Compact Framework Method 특성은 메서드에 적용할 수 있습니다. 
Supported by the .NET Compact Framework Module 특성은 모듈에 적용할 수 있습니다. 

참고

Module은 이식 가능한 실행 파일(.dll 또는 .exe)을 참조하며 Visual Basic 표준 모듈이 아닙니다.

Supported by the .NET Compact Framework Parameter 특성은 매개 변수에 적용할 수 있습니다. 
Supported by the .NET Compact Framework Property 특성은 속성에 적용할 수 있습니다. 
Supported by the .NET Compact Framework ReturnValue 특성은 반환 값에 적용할 수 있습니다. 
Supported by the .NET Compact Framework Struct 특성은 구조체 즉, 값 형식에 적용할 수 있습니다. 

설명

AttributeTargets는 특성을 지정할 수 있는 요소의 종류를 지정하는 AttributeUsageAttribute의 매개 변수로 사용됩니다.

AttributeTargets 열거형 값은 기본 결합을 가져오도록 비트 OR 연산을 사용하여 결합할 수 있습니다.

예제

다음은 AttributeTargets 열거형을 응용한 코드 예제입니다.

Imports System

Module DemoModule
    ' This attribute is only valid on a class.
    <AttributeUsage(AttributeTargets.Class)> _
    Public Class ClassTargetAttribute
        Inherits Attribute
    End Class

    ' This attribute is only valid on a method.
    <AttributeUsage(AttributeTargets.Method)> _
    Public Class MethodTargetAttribute
        Inherits Attribute
    End Class

    ' This attribute is only valid on a constructor.
    <AttributeUsage(AttributeTargets.Constructor)> _
    Public Class ConstructorTargetAttribute 
        Inherits Attribute
    End Class

    ' This attribute is only valid on a field.
    <AttributeUsage(AttributeTargets.Field)> _
    Public Class FieldTargetAttribute 
        Inherits Attribute
    End Class

    ' This attribute is valid on a class or a method.
    <AttributeUsage(AttributeTargets.Class Or AttributeTargets.Method)> _
    Public Class ClassMethodTargetAttribute 
        Inherits Attribute
    End Class

    ' This attribute is valid on any target.
    <AttributeUsage(AttributeTargets.All)> _
    Public Class AllTargetsAttribute 
        Inherits Attribute
    End Class

    <ClassTarget, _
    ClassMethodTarget, _
    AllTargets> _
    Public Class TestClassAttribute
        <ConstructorTarget, _
        AllTargets> _
        Public Sub New
        End Sub

        <MethodTarget, _
        ClassMethodTarget, _
        AllTargets> _
        Public Sub Method1()
        End Sub

        <FieldTarget, _
        AllTargets> _
        Public myInt as Integer
    End Class

    Sub Main()
    End Sub
End Module
using System;

namespace AttTargsCS {
    // This attribute is only valid on a class.
    [AttributeUsage(AttributeTargets.Class)]
    public class ClassTargetAttribute : Attribute {
    }

    // This attribute is only valid on a method.
    [AttributeUsage(AttributeTargets.Method)]
    public class MethodTargetAttribute : Attribute {
    }

    // This attribute is only valid on a constructor.
    [AttributeUsage(AttributeTargets.Constructor)]
    public class ConstructorTargetAttribute : Attribute {
    }

    // This attribute is only valid on a field.
    [AttributeUsage(AttributeTargets.Field)]
    public class FieldTargetAttribute : Attribute {
    }

    // This attribute is valid on a class or a method.
    [AttributeUsage(AttributeTargets.Class|AttributeTargets.Method)]
    public class ClassMethodTargetAttribute : Attribute {
    }

    // This attribute is valid on any target.
    [AttributeUsage(AttributeTargets.All)]
    public class AllTargetsAttribute : Attribute {
    }

    [ClassTarget]
    [ClassMethodTarget]
    [AllTargets]
    public class TestClassAttribute {
        [ConstructorTarget]
        [AllTargets]
        TestClassAttribute() {
        }

        [MethodTarget]
        [ClassMethodTarget]
        [AllTargets]
        public void Method1() {
        }

        [FieldTarget]
        [AllTargets]
        public int myInt;

        static void Main(string[] args) {
        }
    }
}
using namespace System;

namespace AttTargsCS
{

   // This attribute is only valid on a class.

   [AttributeUsage(AttributeTargets::Class)]
   public ref class ClassTargetAttribute: public Attribute{};


   // This attribute is only valid on a method.

   [AttributeUsage(AttributeTargets::Method)]
   public ref class MethodTargetAttribute: public Attribute{};


   // This attribute is only valid on a constructor.

   [AttributeUsage(AttributeTargets::Constructor)]
   public ref class ConstructorTargetAttribute: public Attribute{};


   // This attribute is only valid on a field.

   [AttributeUsage(AttributeTargets::Field)]
   public ref class FieldTargetAttribute: public Attribute{};


   // This attribute is valid on a class or a method.

   [AttributeUsage(AttributeTargets::Class|AttributeTargets::Method)]
   public ref class ClassMethodTargetAttribute: public Attribute{};


   // This attribute is valid on any target.

   [AttributeUsage(AttributeTargets::All)]
   public ref class AllTargetsAttribute: public Attribute{};


   [ClassTarget]
   [ClassMethodTarget]
   [AllTargets]
   public ref class TestClassAttribute
   {
   private:

      [ConstructorTarget]
      [AllTargets]
      TestClassAttribute(){}


   public:

      [MethodTarget]
      [ClassMethodTarget]
      [AllTargets]
      void Method1(){}


      [FieldTarget]
      [AllTargets]
      int myInt;
      static void Main(){}

   };

}
package AttTargsJSL;
import System.*;

// This attribute is only valid on a class.
/** @attribute AttributeUsage(AttributeTargets.Class)
 */
public class ClassTargetAttribute extends Attribute
{
} //ClassTargetAttribute

// This attribute is only valid on a method.
/** @attribute AttributeUsage(AttributeTargets.Method)
 */
public class MethodTargetAttribute extends Attribute
{
} //MethodTargetAttribute

// This attribute is only valid on a constructor.
/** @attribute AttributeUsage(AttributeTargets.Constructor)
 */
public class ConstructorTargetAttribute extends Attribute
{
} //ConstructorTargetAttribute

// This attribute is only valid on a field.
/** @attribute AttributeUsage(AttributeTargets.Field)
 */
public class FieldTargetAttribute extends Attribute
{
} //FieldTargetAttribute

// This attribute is valid on a class or a method.
/** @attribute AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)
 */
public class ClassMethodTargetAttribute extends Attribute
{
} //ClassMethodTargetAttribute

// This attribute is valid on any target.
/** @attribute AttributeUsage(AttributeTargets.All)
 */
public class AllTargetsAttribute extends Attribute
{
} //AllTargetsAttribute

/** @attribute ClassTarget()
 */
/** @attribute ClassMethodTarget()
 */
/** @attribute AllTargets()
 */
public class TestClassAttribute
{
    /** @attribute.ConstructorTarget ConstructorTarget()
     */
    /** @attribute AllTargets()
     */
    TestClassAttribute()
    {
    } //TestClassAttribute

    /** @attribute MethodTarget()
     */
    /** @attribute ClassMethodTarget()
     */
    /** @attribute AllTargets()
     */
    public void Method1()
    {
    } //Method1

    /** @attribute FieldTarget()
     */
    /** @attribute AllTargets()
     */
    public int myInt;

    public static void main(String[] args)
    {
    } //main
} //TestClassAttribute
import System;

package AttTargsJS {
    // This attribute is only valid on a class.
    AttributeUsage(AttributeTargets.Class)
    public class ClassTargetAttribute extends Attribute {
    }

    // This attribute is only valid on a method.
    AttributeUsage(AttributeTargets.Method)
    public class MethodTargetAttribute extends Attribute {
    }

    // This attribute is only valid on a constructor.
    AttributeUsage(AttributeTargets.Constructor)
    public class ConstructorTargetAttribute extends Attribute {
    }

    // This attribute is only valid on a field.
    AttributeUsage(AttributeTargets.Field)
    public class FieldTargetAttribute extends Attribute {
    }

    // This attribute is valid on a class or a method.
    AttributeUsage(AttributeTargets.Class|AttributeTargets.Method)
    public class ClassMethodTargetAttribute extends Attribute {
    }

    // This attribute is valid on any target.
    AttributeUsage(AttributeTargets.All)
    public class AllTargetsAttribute extends Attribute {
    }

    ClassTargetAttribute
        ClassMethodTargetAttribute
        AllTargetsAttribute
    public class TestClassAttribute {
        ConstructorTargetAttribute
        AllTargetsAttribute
        function TestClassAttribute() {
        }

        MethodTargetAttribute
                ClassMethodTargetAttribute
                AllTargetsAttribute
        public function Method1() {
        }

        FieldTargetAttribute
                AllTargetsAttribute
        public var myInt : int;

        static function Main(args : String[]) {
        }
    }
}

플랫폼

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, 1.0에서 지원

참고 항목

참조

System 네임스페이스
AttributeUsageAttribute