반응형

http://msdn.microsoft.com/ko-kr/library/system.componentmodel.descriptionattribute.aspx


속성 또는 이벤트에 대한 설명을 지정합니다.

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

C#
[AttributeUsageAttribute(AttributeTargets.All)]
public class DescriptionAttribute : Attribute

비주얼 디자이너는 속성 창 등에서 구성 요소 멤버를 참조할 때 지정된 설명을 표시할 수 있습니다. 이 특성의 값에 액세스하려면 Description을 호출합니다.

자세한 내용은 특성 개요특성을 사용하여 메타데이터 확장을 참조하십시오.

다음 예제에서는 MyImage 속성을 만듭니다. 이 속성에는 DescriptionAttributeCategoryAttribute의 두 가지 특성이 있습니다.

[Description("The image associated with the control"),Category("Appearance")] 
 public Image MyImage {
    get {
       // Insert code here.
       return image1;
    }
    set {
       // Insert code here.
    }
 }

다음 예제에서는 MyImage의 설명을 가져옵니다. 먼저 코드는 개체의 모든 속성이 들어 있는 PropertyDescriptorCollection을 가져옵니다. 다음에는 PropertyDescriptorCollection으로 인덱싱하여 MyImage를 가져옵니다. 그런 다음 이 속성의 특성을 반환하여 특성 변수에 저장합니다.

이 예제에서는 AttributeCollection에서 DescriptionAttribute를 검색한 다음 이를 콘솔 화면에 쓰는 방법으로 설명을 출력합니다.

// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["MyImage"].Attributes;

 /* Prints the description by retrieving the DescriptionAttribute 
  * from the AttributeCollection. */
 DescriptionAttribute myAttribute = 
    (DescriptionAttribute)attributes[typeof(DescriptionAttribute)];
 Console.WriteLine(myAttribute.Description);
이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.

반응형

'프로젝트 > 메신저관련' 카테고리의 다른 글

String..::.ToCharArray  (0) 2010.02.22
extern(C# 참조)  (0) 2010.02.19
Collection / ArrayList / HashTable  (0) 2010.02.19

+ Recent posts