|
이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오. 추가 정보
|
번역
원본
|
MemberInfo.IsDefined 메서드
.NET Framework 4.5
네임스페이스: System.Reflection
어셈블리: mscorlib(mscorlib.dll)
매개 변수
- attributeType
- 형식: System.Type
검색할 사용자 지정 특성의 형식입니다. 검색 대상에는 파생 형식이 포함됩니다.
- inherit
- 형식: System.Boolean
특성을 찾기 위해 이 멤버의 상속 체인을 검색하려면 true로 설정하고, 그렇지 않으면 false로 설정합니다. 이 매개 변수는 속성과 이벤트의 경우 무시됩니다. 설명 부분을 참조하십시오.
구현
ICustomAttributeProvider.IsDefined(Type, Boolean)_MemberInfo.IsDefined(Type, Boolean)
참고 |
|---|
using System; using System.Reflection; // Define a custom attribute with one named parameter. [AttributeUsage(AttributeTargets.All)] public class MyAttribute : Attribute { private string myName; public MyAttribute(string name) { myName = name; } public string Name { get { return myName; } } } // Define a class that has the custom attribute associated with one of its members. public class MyClass1 { [MyAttribute("This is an example attribute.")] public void MyMethod(int i) { return; } } public class MemberInfo_GetCustomAttributes_IsDefined { public static void Main() { try { // Get the type of MyClass1. Type myType = typeof(MyClass1); // Get the members associated with MyClass1. MemberInfo[] myMembers = myType.GetMembers(); // Display the attributes for each of the members of MyClass1. for(int i = 0; i < myMembers.Length; i++) { // Display the attribute if it is of type MyAttribute. if(myMembers[i].IsDefined(typeof(MyAttribute), false)) { Object[] myAttributes = myMembers[i].GetCustomAttributes(typeof(MyAttribute), false); Console.WriteLine("\nThe attributes of type MyAttribute for the member {0} are: \n", myMembers[i]); for(int j = 0; j < myAttributes.Length; j++) // Display the value associated with the attribute. Console.WriteLine("The value of the attribute is : \"{0}\"", ((MyAttribute)myAttributes[j]).Name); } } } catch(Exception e) { Console.WriteLine("An exception occurred: {0}", e.Message); } } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008(서버 코어 역할은 지원되지 않음), Windows Server 2008 R2(서버 코어 역할은 SP1 이상에서 지원, Itanium은 지원되지 않음)
.NET Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.
참고