Attribute Class
 

Represents the base class for custom attributes.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

SystemObject
  SystemAttribute
     Microsoft.Build.FrameworkLoadInSeparateAppDomainAttribute
     Microsoft.Build.FrameworkOutputAttribute
     Microsoft.Build.FrameworkRequiredAttribute
     Microsoft.Build.FrameworkRequiredRuntimeAttribute
     Microsoft.Build.FrameworkRunInMTAAttribute
     Microsoft.Build.FrameworkRunInSTAAttribute
     Microsoft.JScriptExpando
     Microsoft.JScriptHide
     Microsoft.JScriptJSFunctionAttribute
     Microsoft.JScriptNotRecommended
     Microsoft.JScriptOverride
     Microsoft.JScriptReferenceAttribute
     Microsoft.SqlServer.ServerSqlFacetAttribute
     Microsoft.SqlServer.ServerSqlFunctionAttribute
     Microsoft.SqlServer.ServerSqlProcedureAttribute
     Microsoft.SqlServer.ServerSqlTriggerAttribute
     Microsoft.SqlServer.ServerSqlUserDefinedAggregateAttribute
     Microsoft.SqlServer.ServerSqlUserDefinedTypeAttribute
     Microsoft.VisualBasicComClassAttribute
     Microsoft.VisualBasic.CompilerServicesDesignerGeneratedAttribute
     Microsoft.VisualBasic.CompilerServicesOptionCompareAttribute
     Microsoft.VisualBasic.CompilerServicesOptionTextAttribute
     Microsoft.VisualBasic.CompilerServicesStandardModuleAttribute
     Microsoft.VisualBasicHideModuleNameAttribute
     Microsoft.VisualBasicMyGroupCollectionAttribute
     Microsoft.VisualBasicVBFixedArrayAttribute
     Microsoft.VisualBasicVBFixedStringAttribute
     Microsoft.VisualCDebugInfoInPDBAttribute
     Microsoft.VisualCDecoratedNameAttribute
     Microsoft.VisualCMiscellaneousBitsAttribute
     System.ActivitiesOverloadGroupAttribute
     System.Activities.PresentationActivityDesignerOptionsAttribute
     System.Activities.PresentationDefaultTypeArgumentAttribute
     System.Activities.Presentation.ExpressionsExpressionMorphHelperAttribute
     System.Activities.Presentation.PropertyEditingEditorOptionAttribute
     System.Activities.Presentation.PropertyEditingEditorReuseAttribute
     System.Activities.PresentationTypeResolvingOptionsAttribute
     System.Activities.Presentation.View.OutlineViewHidePropertyInOutlineViewAttribute
     System.Activities.Presentation.View.OutlineViewShowInOutlineViewAttribute
     System.Activities.Presentation.View.OutlineViewShowPropertyInOutlineViewAsSiblingAttribute
     System.Activities.Presentation.View.OutlineViewShowPropertyInOutlineViewAttribute
     System.ActivitiesRequiredArgumentAttribute
     System.AddInAddInAttribute
     System.AddIn.PipelineAddInAdapterAttribute
     System.AddIn.PipelineAddInBaseAttribute
     System.AddIn.PipelineAddInContractAttribute
     System.AddIn.PipelineHostAdapterAttribute
     System.AddIn.PipelineQualificationDataAttribute
     SystemAttributeUsageAttribute
     SystemCLSCompliantAttribute
     System.CodeDom.CompilerGeneratedCodeAttribute
     System.ComponentModelAmbientValueAttribute
     System.ComponentModelAttributeProviderAttribute
     System.ComponentModelBindableAttribute
     System.ComponentModelBrowsableAttribute
     System.ComponentModelCategoryAttribute
     System.ComponentModelComplexBindingPropertiesAttribute
     System.ComponentModel.CompositionCatalogReflectionContextAttribute
     System.ComponentModel.CompositionExportAttribute
     System.ComponentModel.CompositionExportMetadataAttribute
     System.ComponentModel.CompositionImportAttribute
     System.ComponentModel.CompositionImportingConstructorAttribute
     System.ComponentModel.CompositionImportManyAttribute
     System.ComponentModel.CompositionMetadataAttributeAttribute
     System.ComponentModel.CompositionMetadataViewImplementationAttribute
     System.ComponentModel.CompositionPartCreationPolicyAttribute
     System.ComponentModel.CompositionPartMetadataAttribute
     System.ComponentModel.CompositionPartNotDiscoverableAttribute
     System.ComponentModel.DataAnnotationsAssociationAttribute
     System.ComponentModel.DataAnnotationsBindableTypeAttribute
     System.ComponentModel.DataAnnotationsConcurrencyCheckAttribute
     System.ComponentModel.DataAnnotationsDisplayAttribute
     System.ComponentModel.DataAnnotationsDisplayColumnAttribute
     System.ComponentModel.DataAnnotationsDisplayFormatAttribute
     System.ComponentModel.DataAnnotationsEditableAttribute
     System.ComponentModel.DataAnnotationsFilterUIHintAttribute
     System.ComponentModel.DataAnnotationsKeyAttribute
     System.ComponentModel.DataAnnotationsMetadataTypeAttribute
     System.ComponentModel.DataAnnotationsScaffoldColumnAttribute
     System.ComponentModel.DataAnnotationsScaffoldTableAttribute
     System.ComponentModel.DataAnnotations.SchemaColumnAttribute
     System.ComponentModel.DataAnnotations.SchemaComplexTypeAttribute
     System.ComponentModel.DataAnnotations.SchemaDatabaseGeneratedAttribute
     System.ComponentModel.DataAnnotations.SchemaForeignKeyAttribute
     System.ComponentModel.DataAnnotations.SchemaInversePropertyAttribute
     System.ComponentModel.DataAnnotations.SchemaNotMappedAttribute
     System.ComponentModel.DataAnnotations.SchemaTableAttribute
     System.ComponentModel.DataAnnotationsTimestampAttribute
     System.ComponentModel.DataAnnotationsUIHintAttribute
     System.ComponentModel.DataAnnotationsValidationAttribute
     System.ComponentModelDataObjectAttribute
     System.ComponentModelDataObjectFieldAttribute
     System.ComponentModelDataObjectMethodAttribute
     System.ComponentModelDefaultBindingPropertyAttribute
     System.ComponentModelDefaultEventAttribute
     System.ComponentModelDefaultPropertyAttribute
     System.ComponentModelDefaultValueAttribute
     System.ComponentModelDescriptionAttribute
     System.ComponentModel.DesignHelpKeywordAttribute
     System.ComponentModel.DesignProjectTargetFrameworkAttribute
     System.ComponentModel.Design.SerializationDefaultSerializationProviderAttribute
     System.ComponentModel.Design.SerializationDesignerSerializerAttribute
     System.ComponentModel.Design.SerializationRootDesignerSerializerAttribute
     System.ComponentModelDesignerAttribute
     System.ComponentModelDesignerCategoryAttribute
     System.ComponentModelDesignerSerializationVisibilityAttribute
     System.ComponentModelDesignOnlyAttribute
     System.ComponentModelDesignTimeVisibleAttribute
     System.ComponentModelDisplayNameAttribute
     System.ComponentModelEditorAttribute
     System.ComponentModelEditorBrowsableAttribute
     System.ComponentModelExtenderProvidedPropertyAttribute
     System.ComponentModelImmutableObjectAttribute
     System.ComponentModelInheritanceAttribute
     System.ComponentModelInitializationEventAttribute
     System.ComponentModelInstallerTypeAttribute
     System.ComponentModelLicenseProviderAttribute
     System.ComponentModelListBindableAttribute
     System.ComponentModelLocalizableAttribute
     System.ComponentModelLookupBindingPropertiesAttribute
     System.ComponentModelMergablePropertyAttribute
     System.ComponentModelNotifyParentPropertyAttribute
     System.ComponentModelParenthesizePropertyNameAttribute
     System.ComponentModelPasswordPropertyTextAttribute
     System.ComponentModelPropertyFilterAttribute
     System.ComponentModelPropertyTabAttribute
     System.ComponentModelProvidePropertyAttribute
     System.ComponentModelReadOnlyAttribute
     System.ComponentModelRecommendedAsConfigurableAttribute
     System.ComponentModelRefreshPropertiesAttribute
     System.ComponentModelRunInstallerAttribute
     System.ComponentModelSettingsBindableAttribute
     System.ComponentModelToolboxItemAttribute
     System.ComponentModelToolboxItemFilterAttribute
     System.ComponentModelTypeConverterAttribute
     System.ComponentModelTypeDescriptionProviderAttribute
     System.ConfigurationConfigurationCollectionAttribute
     System.ConfigurationConfigurationPropertyAttribute
     System.ConfigurationConfigurationValidatorAttribute
     System.ConfigurationDefaultSettingValueAttribute
     System.ConfigurationNoSettingsVersionUpgradeAttribute
     System.ConfigurationSettingAttribute
     System.ConfigurationSettingsDescriptionAttribute
     System.ConfigurationSettingsGroupDescriptionAttribute
     System.ConfigurationSettingsGroupNameAttribute
     System.ConfigurationSettingsManageabilityAttribute
     System.ConfigurationSettingsProviderAttribute
     System.ConfigurationSettingsSerializeAsAttribute
     System.ConfigurationSpecialSettingAttribute
     SystemContextStaticAttribute
     System.Data.CommonDbProviderSpecificTypePropertyAttribute
     System.Data.Linq.MappingDataAttribute
     System.Data.Linq.MappingDatabaseAttribute
     System.Data.Linq.MappingFunctionAttribute
     System.Data.Linq.MappingInheritanceMappingAttribute
     System.Data.Linq.MappingParameterAttribute
     System.Data.Linq.MappingProviderAttribute
     System.Data.Linq.MappingResultTypeAttribute
     System.Data.Linq.MappingTableAttribute
     System.Data.MappingEntityViewGenerationAttribute
     System.Data.Objects.DataClassesEdmFunctionAttribute
     System.Data.Objects.DataClassesEdmPropertyAttribute
     System.Data.Objects.DataClassesEdmRelationshipAttribute
     System.Data.Objects.DataClassesEdmSchemaAttribute
     System.Data.Objects.DataClassesEdmTypeAttribute
     System.Data.ServicesChangeInterceptorAttribute
     System.Data.Services.ClientMediaEntryAttribute
     System.Data.Services.ClientMimeTypePropertyAttribute
     System.Data.Services.CommonDataServiceEntityAttribute
     System.Data.Services.CommonDataServiceKeyAttribute
     System.Data.Services.CommonEntityPropertyMappingAttribute
     System.Data.Services.CommonEntitySetAttribute
     System.Data.Services.CommonHasStreamAttribute
     System.Data.ServicesETagAttribute
     System.Data.ServicesIgnorePropertiesAttribute
     System.Data.ServicesMimeTypeAttribute
     System.Data.ServicesQueryInterceptorAttribute
     System.Data.ServicesSingleResultAttribute
     System.Diagnostics.CodeAnalysisExcludeFromCodeCoverageAttribute
     System.Diagnostics.CodeAnalysisSuppressMessageAttribute
     System.DiagnosticsConditionalAttribute
     System.Diagnostics.ContractsContractAbbreviatorAttribute
     System.Diagnostics.ContractsContractArgumentValidatorAttribute
     System.Diagnostics.ContractsContractClassAttribute
     System.Diagnostics.ContractsContractClassForAttribute
     System.Diagnostics.ContractsContractInvariantMethodAttribute
     System.Diagnostics.ContractsContractOptionAttribute
     System.Diagnostics.ContractsContractPublicPropertyNameAttribute
     System.Diagnostics.ContractsContractReferenceAssemblyAttribute
     System.Diagnostics.ContractsContractRuntimeIgnoredAttribute
     System.Diagnostics.ContractsContractVerificationAttribute
     System.Diagnostics.ContractsPureAttribute
     System.DiagnosticsDebuggableAttribute
     System.DiagnosticsDebuggerBrowsableAttribute
     System.DiagnosticsDebuggerDisplayAttribute
     System.DiagnosticsDebuggerHiddenAttribute
     System.DiagnosticsDebuggerNonUserCodeAttribute
     System.DiagnosticsDebuggerStepperBoundaryAttribute
     System.DiagnosticsDebuggerStepThroughAttribute
     System.DiagnosticsDebuggerTypeProxyAttribute
     System.DiagnosticsDebuggerVisualizerAttribute
     System.DiagnosticsSwitchAttribute
     System.DiagnosticsSwitchLevelAttribute
     System.Diagnostics.TracingEventAttribute
     System.Diagnostics.TracingEventDataAttribute
     System.Diagnostics.TracingEventFieldAttribute
     System.Diagnostics.TracingEventIgnoreAttribute
     System.Diagnostics.TracingEventSourceAttribute
     System.Diagnostics.TracingNonEventAttribute
     System.DirectoryServices.AccountManagementDirectoryObjectClassAttribute
     System.DirectoryServices.AccountManagementDirectoryPropertyAttribute
     System.DirectoryServices.AccountManagementDirectoryRdnPrefixAttribute
     System.DrawingBitmapSuffixInSameAssemblyAttribute
     System.DrawingBitmapSuffixInSatelliteAssemblyAttribute
     System.DrawingToolboxBitmapAttribute
     System.EnterpriseServicesApplicationAccessControlAttribute
     System.EnterpriseServicesApplicationActivationAttribute
     System.EnterpriseServicesApplicationIDAttribute
     System.EnterpriseServicesApplicationNameAttribute
     System.EnterpriseServicesApplicationQueuingAttribute
     System.EnterpriseServicesAutoCompleteAttribute
     System.EnterpriseServices.CompensatingResourceManagerApplicationCrmEnabledAttribute
     System.EnterpriseServicesComponentAccessControlAttribute
     System.EnterpriseServicesCOMTIIntrinsicsAttribute
     System.EnterpriseServicesConstructionEnabledAttribute
     System.EnterpriseServicesDescriptionAttribute
     System.EnterpriseServicesEventClassAttribute
     System.EnterpriseServicesEventTrackingEnabledAttribute
     System.EnterpriseServicesExceptionClassAttribute
     System.EnterpriseServicesIISIntrinsicsAttribute
     System.EnterpriseServicesInterfaceQueuingAttribute
     System.EnterpriseServicesJustInTimeActivationAttribute
     System.EnterpriseServicesLoadBalancingSupportedAttribute
     System.EnterpriseServicesMustRunInClientContextAttribute
     System.EnterpriseServicesObjectPoolingAttribute
     System.EnterpriseServicesPrivateComponentAttribute
     System.EnterpriseServicesSecureMethodAttribute
     System.EnterpriseServicesSecurityRoleAttribute
     System.EnterpriseServicesSynchronizationAttribute
     System.EnterpriseServicesTransactionAttribute
     SystemFlagsAttribute
     SystemLoaderOptimizationAttribute
     System.Management.InstrumentationIgnoreMemberAttribute
     System.Management.InstrumentationInstrumentationClassAttribute
     System.Management.InstrumentationInstrumentedAttribute
     System.Management.InstrumentationManagedNameAttribute
     System.Management.InstrumentationManagementEntityAttribute
     System.Management.InstrumentationManagementMemberAttribute
     System.Management.InstrumentationManagementNameAttribute
     System.Management.InstrumentationManagementQualifierAttribute
     System.Management.InstrumentationManagementReferenceAttribute
     System.Management.InstrumentationWmiConfigurationAttribute
     SystemMTAThreadAttribute
     SystemNonSerializedAttribute
     SystemObsoleteAttribute
     SystemParamArrayAttribute
     System.ReflectionAssemblyAlgorithmIdAttribute
     System.ReflectionAssemblyCompanyAttribute
     System.ReflectionAssemblyConfigurationAttribute
     System.ReflectionAssemblyCopyrightAttribute
     System.ReflectionAssemblyCultureAttribute
     System.ReflectionAssemblyDefaultAliasAttribute
     System.ReflectionAssemblyDelaySignAttribute
     System.ReflectionAssemblyDescriptionAttribute
     System.ReflectionAssemblyFileVersionAttribute
     System.ReflectionAssemblyFlagsAttribute
     System.ReflectionAssemblyInformationalVersionAttribute
     System.ReflectionAssemblyKeyFileAttribute
     System.ReflectionAssemblyKeyNameAttribute
     System.ReflectionAssemblyMetadataAttribute
     System.ReflectionAssemblyProductAttribute
     System.ReflectionAssemblySignatureKeyAttribute
     System.ReflectionAssemblyTitleAttribute
     System.ReflectionAssemblyTrademarkAttribute
     System.ReflectionAssemblyVersionAttribute
     System.ReflectionDefaultMemberAttribute
     System.ReflectionObfuscateAssemblyAttribute
     System.ReflectionObfuscationAttribute
     System.ResourcesNeutralResourcesLanguageAttribute
     System.ResourcesSatelliteContractVersionAttribute
     System.RuntimeAssemblyTargetedPatchBandAttribute
     System.Runtime.CompilerServicesAccessedThroughPropertyAttribute
     System.Runtime.CompilerServicesCallerFilePathAttribute
     System.Runtime.CompilerServicesCallerLineNumberAttribute
     System.Runtime.CompilerServicesCallerMemberNameAttribute
     System.Runtime.CompilerServicesCompilationRelaxationsAttribute
     System.Runtime.CompilerServicesCompilerGeneratedAttribute
     System.Runtime.CompilerServicesCompilerGlobalScopeAttribute
     System.Runtime.CompilerServicesCustomConstantAttribute
     System.Runtime.CompilerServicesDecimalConstantAttribute
     System.Runtime.CompilerServicesDefaultDependencyAttribute
     System.Runtime.CompilerServicesDependencyAttribute
     System.Runtime.CompilerServicesDisablePrivateReflectionAttribute
     System.Runtime.CompilerServicesDiscardableAttribute
     System.Runtime.CompilerServicesDynamicAttribute
     System.Runtime.CompilerServicesExtensionAttribute
     System.Runtime.CompilerServicesFixedAddressValueTypeAttribute
     System.Runtime.CompilerServicesFixedBufferAttribute
     System.Runtime.CompilerServicesHasCopySemanticsAttribute
     System.Runtime.CompilerServicesIndexerNameAttribute
     System.Runtime.CompilerServicesInternalsVisibleToAttribute
     System.Runtime.CompilerServicesMethodImplAttribute
     System.Runtime.CompilerServicesNativeCppClassAttribute
     System.Runtime.CompilerServicesReferenceAssemblyAttribute
     System.Runtime.CompilerServicesRequiredAttributeAttribute
     System.Runtime.CompilerServicesRuntimeCompatibilityAttribute
     System.Runtime.CompilerServicesScopelessEnumAttribute
     System.Runtime.CompilerServicesSpecialNameAttribute
     System.Runtime.CompilerServicesStateMachineAttribute
     System.Runtime.CompilerServicesStringFreezingAttribute
     System.Runtime.CompilerServicesSuppressIldasmAttribute
     System.Runtime.CompilerServicesTupleElementNamesAttribute
     System.Runtime.CompilerServicesTypeForwardedFromAttribute
     System.Runtime.CompilerServicesTypeForwardedToAttribute
     System.Runtime.CompilerServicesUnsafeValueTypeAttribute
     System.Runtime.ConstrainedExecutionPrePrepareMethodAttribute
     System.Runtime.ConstrainedExecutionReliabilityContractAttribute
     System.Runtime.ExceptionServicesHandleProcessCorruptedStateExceptionsAttribute
     System.Runtime.InteropServicesAllowReversePInvokeCallsAttribute
     System.Runtime.InteropServicesAutomationProxyAttribute
     System.Runtime.InteropServicesBestFitMappingAttribute
     System.Runtime.InteropServicesClassInterfaceAttribute
     System.Runtime.InteropServicesCoClassAttribute
     System.Runtime.InteropServicesComAliasNameAttribute
     System.Runtime.InteropServicesComCompatibleVersionAttribute
     System.Runtime.InteropServicesComConversionLossAttribute
     System.Runtime.InteropServicesComDefaultInterfaceAttribute
     System.Runtime.InteropServicesComEventInterfaceAttribute
     System.Runtime.InteropServicesComImportAttribute
     System.Runtime.InteropServicesComRegisterFunctionAttribute
     System.Runtime.InteropServicesComSourceInterfacesAttribute
     System.Runtime.InteropServicesComUnregisterFunctionAttribute
     System.Runtime.InteropServicesComVisibleAttribute
     System.Runtime.InteropServicesDefaultCharSetAttribute
     System.Runtime.InteropServicesDefaultDllImportSearchPathsAttribute
     System.Runtime.InteropServicesDefaultParameterValueAttribute
     System.Runtime.InteropServicesDispIdAttribute
     System.Runtime.InteropServicesDllImportAttribute
     System.Runtime.InteropServicesFieldOffsetAttribute
     System.Runtime.InteropServicesGuidAttribute
     System.Runtime.InteropServicesIDispatchImplAttribute
     System.Runtime.InteropServicesImportedFromTypeLibAttribute
     System.Runtime.InteropServicesInAttribute
     System.Runtime.InteropServicesInterfaceTypeAttribute
     System.Runtime.InteropServicesLCIDConversionAttribute
     System.Runtime.InteropServicesManagedToNativeComInteropStubAttribute
     System.Runtime.InteropServicesMarshalAsAttribute
     System.Runtime.InteropServicesOptionalAttribute
     System.Runtime.InteropServicesOutAttribute
     System.Runtime.InteropServicesPreserveSigAttribute
     System.Runtime.InteropServicesPrimaryInteropAssemblyAttribute
     System.Runtime.InteropServicesProgIdAttribute
     System.Runtime.InteropServicesSetWin32ContextInIDispatchAttribute
     System.Runtime.InteropServicesStructLayoutAttribute
     System.Runtime.InteropServicesTypeIdentifierAttribute
     System.Runtime.InteropServicesTypeLibFuncAttribute
     System.Runtime.InteropServicesTypeLibImportClassAttribute
     System.Runtime.InteropServicesTypeLibTypeAttribute
     System.Runtime.InteropServicesTypeLibVarAttribute
     System.Runtime.InteropServicesTypeLibVersionAttribute
     System.Runtime.InteropServicesUnmanagedFunctionPointerAttribute
     System.Runtime.InteropServices.WindowsRuntimeDefaultInterfaceAttribute
     System.Runtime.InteropServices.WindowsRuntimeInterfaceImplementedInVersionAttribute
     System.Runtime.InteropServices.WindowsRuntimeReadOnlyArrayAttribute
     System.Runtime.InteropServices.WindowsRuntimeReturnValueNameAttribute
     System.Runtime.InteropServices.WindowsRuntimeWriteOnlyArrayAttribute
     System.Runtime.Remoting.ContextsContextAttribute
     System.Runtime.Remoting.MessagingOneWayAttribute
     System.Runtime.Remoting.MetadataSoapAttribute
     System.Runtime.Remoting.ProxiesProxyAttribute
     System.Runtime.SerializationCollectionDataContractAttribute
     System.Runtime.SerializationContractNamespaceAttribute
     System.Runtime.SerializationDataContractAttribute
     System.Runtime.SerializationDataMemberAttribute
     System.Runtime.SerializationEnumMemberAttribute
     System.Runtime.SerializationIgnoreDataMemberAttribute
     System.Runtime.SerializationKnownTypeAttribute
     System.Runtime.SerializationOnDeserializedAttribute
     System.Runtime.SerializationOnDeserializingAttribute
     System.Runtime.SerializationOnSerializedAttribute
     System.Runtime.SerializationOnSerializingAttribute
     System.Runtime.SerializationOptionalFieldAttribute
     System.RuntimeTargetedPatchingOptOutAttribute
     System.Runtime.VersioningComponentGuaranteesAttribute
     System.Runtime.VersioningResourceConsumptionAttribute
     System.Runtime.VersioningResourceExposureAttribute
     System.Runtime.VersioningTargetFrameworkAttribute
     System.SecurityAllowPartiallyTrustedCallersAttribute
     System.Security.PermissionsSecurityAttribute
     System.SecuritySecurityCriticalAttribute
     System.SecuritySecurityRulesAttribute
     System.SecuritySecuritySafeCriticalAttribute
     System.SecuritySecurityTransparentAttribute
     System.SecuritySecurityTreatAsSafeAttribute
     System.SecuritySuppressUnmanagedCodeSecurityAttribute
     System.SecurityUnverifiableCodeAttribute
     SystemSerializableAttribute
     System.ServiceModel.ActivationAspNetCompatibilityRequirementsAttribute
     System.ServiceModel.ActivationServiceActivationBuildProviderAttribute
     System.ServiceModel.Activities.DescriptionWorkflowContractBehaviorAttribute
     System.ServiceModelCallbackBehaviorAttribute
     System.ServiceModelDataContractFormatAttribute
     System.ServiceModelDeliveryRequirementsAttribute
     System.ServiceModel.DescriptionDurableOperationAttribute
     System.ServiceModel.DescriptionDurableServiceAttribute
     System.ServiceModelFaultContractAttribute
     System.ServiceModelMessageContractAttribute
     System.ServiceModelMessageContractMemberAttribute
     System.ServiceModelMessageParameterAttribute
     System.ServiceModelMessagePropertyAttribute
     System.ServiceModelOperationBehaviorAttribute
     System.ServiceModelOperationContractAttribute
     System.ServiceModelReceiveContextEnabledAttribute
     System.ServiceModelServiceBehaviorAttribute
     System.ServiceModelServiceContractAttribute
     System.ServiceModelServiceKnownTypeAttribute
     System.ServiceModelTransactionFlowAttribute
     System.ServiceModel.WebAspNetCacheProfileAttribute
     System.ServiceModel.WebJavascriptCallbackBehaviorAttribute
     System.ServiceModel.WebWebGetAttribute
     System.ServiceModel.WebWebInvokeAttribute
     System.ServiceModelXmlSerializerFormatAttribute
     SystemSTAThreadAttribute
     SystemThreadStaticAttribute
     System.Web.CompilationBuildProviderAppliesToAttribute
     System.Web.CompilationDesignTimeResourceProviderFactoryAttribute
     System.Web.CompilationExpressionEditorAttribute
     System.Web.CompilationExpressionPrefixAttribute
     System.Web.CompilationFolderLevelBuildProviderAppliesToAttribute
     System.Web.DynamicDataTableNameAttribute
     System.Web.HostingCustomLoaderAttribute
     System.Web.ModelBindingBindingBehaviorAttribute
     System.Web.ModelBindingExtensibleModelBinderAttribute
     System.Web.ModelBindingModelBinderProviderOptionsAttribute
     System.Web.ModelBindingUserProfileAttribute
     System.Web.ModelBindingValueProviderSourceAttribute
     System.WebPreApplicationStartMethodAttribute
     System.Web.ProfileCustomProviderDataAttribute
     System.Web.ProfileProfileProviderAttribute
     System.Web.ProfileSettingsAllowAnonymousAttribute
     System.Web.ScriptAjaxFrameworkAssemblyAttribute
     System.Web.Script.SerializationScriptIgnoreAttribute
     System.Web.Script.ServicesGenerateScriptTypeAttribute
     System.Web.Script.ServicesScriptMethodAttribute
     System.Web.Script.ServicesScriptServiceAttribute
     System.Web.Services.ConfigurationXmlFormatExtensionAttribute
     System.Web.Services.ConfigurationXmlFormatExtensionPointAttribute
     System.Web.Services.ConfigurationXmlFormatExtensionPrefixAttribute
     System.Web.Services.ProtocolsHttpMethodAttribute
     System.Web.Services.ProtocolsMatchAttribute
     System.Web.Services.ProtocolsSoapDocumentMethodAttribute
     System.Web.Services.ProtocolsSoapDocumentServiceAttribute
     System.Web.Services.ProtocolsSoapExtensionAttribute
     System.Web.Services.ProtocolsSoapHeaderAttribute
     System.Web.Services.ProtocolsSoapRpcMethodAttribute
     System.Web.Services.ProtocolsSoapRpcServiceAttribute
     System.Web.ServicesWebMethodAttribute
     System.Web.ServicesWebServiceAttribute
     System.Web.ServicesWebServiceBindingAttribute
     System.Web.UIConstructorNeedsTagAttribute
     System.Web.UIControlBuilderAttribute
     System.Web.UIControlValuePropertyAttribute
     System.Web.UICssClassPropertyAttribute
     System.Web.UIDataBindingHandlerAttribute
     System.Web.UIDataKeyPropertyAttribute
     System.Web.UI.Design.DirectivesDirectiveAttribute
     System.Web.UI.Design.DirectivesSchemaElementNameAttribute
     System.Web.UI.DesignSupportsPreviewControlAttribute
     System.Web.UIFileLevelControlBuilderAttribute
     System.Web.UIFilterableAttribute
     System.Web.UIIDReferencePropertyAttribute
     System.Web.UI.MobileControlsDesignerAdapterAttribute
     System.Web.UI.MobileControlsDeviceOverridableAttribute
     System.Web.UI.MobileControlsObjectListTitleAttribute
     System.Web.UI.MobileControlsPersistNameAttribute
     System.Web.UINonVisualControlAttribute
     System.Web.UIParseChildrenAttribute
     System.Web.UIPartialCachingAttribute
     System.Web.UIPersistChildrenAttribute
     System.Web.UIPersistenceModeAttribute
     System.Web.UIScriptResourceAttribute
     System.Web.UISupportsEventValidationAttribute
     System.Web.UITagPrefixAttribute
     System.Web.UITargetControlTypeAttribute
     System.Web.UITemplateContainerAttribute
     System.Web.UITemplateInstanceAttribute
     System.Web.UIThemeableAttribute
     System.Web.UIToolboxDataAttribute
     System.Web.UIUrlPropertyAttribute
     System.Web.UIValidationPropertyAttribute
     System.Web.UIVerificationAttribute
     System.Web.UIViewStateModeByIdAttribute
     System.Web.UI.WebControls.WebPartsConnectionConsumerAttribute
     System.Web.UI.WebControls.WebPartsConnectionProviderAttribute
     System.Web.UI.WebControls.WebPartsPersonalizableAttribute
     System.Web.UI.WebControls.WebPartsWebBrowsableAttribute
     System.Web.UI.WebControls.WebPartsWebDescriptionAttribute
     System.Web.UI.WebControls.WebPartsWebDisplayNameAttribute
     System.Web.UI.WebControls.WebPartsWebPartTransformerAttribute
     System.Web.UIWebResourceAttribute
     System.WindowsAttachedPropertyBrowsableAttribute
     System.Windows.DataValueConversionAttribute
     System.Windows.DocumentsTextElementEditingBehaviorAttribute
     System.Windows.FormsAxHostClsidAttribute
     System.Windows.FormsAxHostTypeLibraryTimeStampAttribute
     System.Windows.FormsDataGridViewColumnDesignTimeVisibleAttribute
     System.Windows.Forms.DesignToolStripItemDesignerAvailabilityAttribute
     System.Windows.FormsDockingAttribute
     System.Windows.FormsRelatedImageListAttribute
     System.WindowsLocalizabilityAttribute
     System.Windows.MarkupAcceptedMarkupExtensionExpressionTypeAttribute
     System.Windows.MarkupAmbientAttribute
     System.Windows.MarkupConstructorArgumentAttribute
     System.Windows.MarkupContentPropertyAttribute
     System.Windows.MarkupContentWrapperAttribute
     System.Windows.MarkupDependsOnAttribute
     System.Windows.MarkupDesignerSerializationOptionsAttribute
     System.Windows.MarkupDictionaryKeyPropertyAttribute
     System.Windows.MarkupMarkupExtensionBracketCharactersAttribute
     System.Windows.MarkupMarkupExtensionReturnTypeAttribute
     System.Windows.MarkupNameScopePropertyAttribute
     System.Windows.MarkupRootNamespaceAttribute
     System.Windows.MarkupRuntimeNamePropertyAttribute
     System.Windows.MarkupTrimSurroundingWhitespaceAttribute
     System.Windows.MarkupUidPropertyAttribute
     System.Windows.MarkupUsableDuringInitializationAttribute
     System.Windows.MarkupValueSerializerAttribute
     System.Windows.MarkupWhitespaceSignificantCollectionAttribute
     System.Windows.MarkupXamlDeferLoadAttribute
     System.Windows.MarkupXamlSetMarkupExtensionAttribute
     System.Windows.MarkupXamlSetTypeConverterAttribute
     System.Windows.MarkupXmlLangPropertyAttribute
     System.Windows.MarkupXmlnsCompatibleWithAttribute
     System.Windows.MarkupXmlnsDefinitionAttribute
     System.Windows.MarkupXmlnsPrefixAttribute
     System.Windows.MediaDisableDpiAwarenessAttribute
     System.Windows.ResourcesAssemblyAssociatedContentFileAttribute
     System.WindowsStyleTypedPropertyAttribute
     System.WindowsTemplatePartAttribute
     System.WindowsTemplateVisualStateAttribute
     System.WindowsThemeInfoAttribute
     System.Workflow.ActivitiesCorrelationAliasAttribute
     System.Workflow.ActivitiesCorrelationInitializerAttribute
     System.Workflow.ActivitiesCorrelationParameterAttribute
     System.Workflow.ActivitiesExternalDataExchangeAttribute
     System.Workflow.Activities.RulesRuleAttribute
     System.Workflow.ComponentModelAlternateFlowActivityAttribute
     System.Workflow.ComponentModel.CompilerActivityCodeGeneratorAttribute
     System.Workflow.ComponentModel.CompilerActivityValidatorAttribute
     System.Workflow.ComponentModel.CompilerAttributeInfoAttribute
     System.Workflow.ComponentModel.CompilerValidationOptionAttribute
     System.Workflow.ComponentModel.CompilerWorkflowMarkupSourceAttribute
     System.Workflow.ComponentModel.DesignActivityDesignerThemeAttribute
     System.Workflow.ComponentModel.DesignTypeFilterProviderAttribute
     System.Workflow.ComponentModelPersistOnCloseAttribute
     System.Workflow.ComponentModel.SerializationConstructorArgumentAttribute
     System.Workflow.ComponentModel.SerializationContentPropertyAttribute
     System.Workflow.ComponentModel.SerializationRuntimeNamePropertyAttribute
     System.Workflow.ComponentModel.SerializationXmlnsDefinitionAttribute
     System.Workflow.ComponentModel.SerializationXmlnsPrefixAttribute
     System.Workflow.Runtime.DebugEngineWorkflowDebuggerSteppingAttribute
     System.Workflow.Runtime.TrackingPreviousTrackingServiceAttribute
     System.Xml.SerializationSoapAttributeAttribute
     System.Xml.SerializationSoapElementAttribute
     System.Xml.SerializationSoapEnumAttribute
     System.Xml.SerializationSoapIgnoreAttribute
     System.Xml.SerializationSoapIncludeAttribute
     System.Xml.SerializationSoapTypeAttribute
     System.Xml.SerializationXmlAnyAttributeAttribute
     System.Xml.SerializationXmlAnyElementAttribute
     System.Xml.SerializationXmlArrayAttribute
     System.Xml.SerializationXmlArrayItemAttribute
     System.Xml.SerializationXmlAttributeAttribute
     System.Xml.SerializationXmlChoiceIdentifierAttribute
     System.Xml.SerializationXmlElementAttribute
     System.Xml.SerializationXmlEnumAttribute
     System.Xml.SerializationXmlIgnoreAttribute
     System.Xml.SerializationXmlIncludeAttribute
     System.Xml.SerializationXmlNamespaceDeclarationsAttribute
     System.Xml.SerializationXmlRootAttribute
     System.Xml.SerializationXmlSchemaProviderAttribute
     System.Xml.SerializationXmlSerializerAssemblyAttribute
     System.Xml.SerializationXmlSerializerVersionAttribute
     System.Xml.SerializationXmlTextAttribute
     System.Xml.SerializationXmlTypeAttribute

[SerializableAttribute]
[AttributeUsageAttribute(AttributeTargets.All, Inherited = true, 
	AllowMultiple = false)]
[ClassInterfaceAttribute(ClassInterfaceType.None)]
[ComVisibleAttribute(true)]
public abstract class Attribute : _Attribute
[SerializableAttribute]
[AttributeUsageAttribute(AttributeTargets::All, Inherited = true, 
	AllowMultiple = false)]
[ClassInterfaceAttribute(ClassInterfaceType::None)]
[ComVisibleAttribute(true)]
public ref class Attribute abstract : _Attribute
[<AbstractClass>]
[<SerializableAttribute>]
[<AttributeUsageAttribute(AttributeTargets.All, Inherited = true,
    AllowMultiple = false)>]
[<ClassInterfaceAttribute(ClassInterfaceType.None)>]
[<ComVisibleAttribute(true)>]
type Attribute = 
    class
        interface _Attribute
    end
<SerializableAttribute>
<AttributeUsageAttribute(AttributeTargets.All, Inherited := True,
	AllowMultiple := False)>
<ClassInterfaceAttribute(ClassInterfaceType.None)>
<ComVisibleAttribute(True)>
Public MustInherit Class Attribute
	Implements _Attribute
NameDescription
System_CAPS_protmethod Attribute

Initializes a new instance of the Attribute class.

NameDescription
System_CAPS_pubproperty

When implemented in a derived class, gets a unique identifier for this Attribute.

NameDescription
System_CAPS_pubmethod Equals

This API supports the product infrastructure and is not intended to be used directly from your code. Returns a value that indicates whether this instance is equal to a specified object.(Overrides ObjectEquals.)

System_CAPS_protmethod Finalize

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethod System_CAPS_static GetCustomAttribute

Retrieves a custom attribute applied to a specified assembly. Parameters specify the assembly and the type of the custom attribute to search for.

System_CAPS_pubmethod System_CAPS_static GetCustomAttribute

Retrieves a custom attribute applied to an assembly. Parameters specify the assembly, the type of the custom attribute to search for, and an ignored search option.

System_CAPS_pubmethod System_CAPS_static GetCustomAttribute

Retrieves a custom attribute applied to a member of a type. Parameters specify the member, and the type of the custom attribute to search for.

System_CAPS_pubmethod System_CAPS_static GetCustomAttribute

Retrieves a custom attribute applied to a member of a type. Parameters specify the member, the type of the custom attribute to search for, and whether to search ancestors of the member.

System_CAPS_pubmethod System_CAPS_static GetCustomAttribute

Retrieves a custom attribute applied to a module. Parameters specify the module, and the type of the custom attribute to search for.

System_CAPS_pubmethod System_CAPS_static GetCustomAttribute

Retrieves a custom attribute applied to a module. Parameters specify the module, the type of the custom attribute to search for, and an ignored search option.

System_CAPS_pubmethod System_CAPS_static GetCustomAttribute

Retrieves a custom attribute applied to a method parameter. Parameters specify the method parameter, and the type of the custom attribute to search for.

System_CAPS_pubmethod System_CAPS_static GetCustomAttribute

Retrieves a custom attribute applied to a method parameter. Parameters specify the method parameter, the type of the custom attribute to search for, and whether to search ancestors of the method parameter.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to an assembly. A parameter specifies the assembly.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to an assembly. Parameters specify the assembly, and an ignored search option.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to an assembly. Parameters specify the assembly, and the type of the custom attribute to search for.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to an assembly. Parameters specify the assembly, the type of the custom attribute to search for, and an ignored search option.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to a member of a type. A parameter specifies the member.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to a member of a type. Parameters specify the member, the type of the custom attribute to search for, and whether to search ancestors of the member.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to a member of a type. Parameters specify the member, and the type of the custom attribute to search for.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to a member of a type. Parameters specify the member, the type of the custom attribute to search for, and whether to search ancestors of the member.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to a module. A parameter specifies the module.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to a module. Parameters specify the module, and an ignored search option.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to a module. Parameters specify the module, and the type of the custom attribute to search for.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to a module. Parameters specify the module, the type of the custom attribute to search for, and an ignored search option.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to a method parameter. A parameter specifies the method parameter.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to a method parameter. Parameters specify the method parameter, and whether to search ancestors of the method parameter.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to a method parameter. Parameters specify the method parameter, and the type of the custom attribute to search for.

System_CAPS_pubmethod System_CAPS_static GetCustomAttributes

Retrieves an array of the custom attributes applied to a method parameter. Parameters specify the method parameter, the type of the custom attribute to search for, and whether to search ancestors of the method parameter.

System_CAPS_pubmethod GetHashCode

Returns the hash code for this instance.(Overrides ObjectGetHashCode.)

System_CAPS_pubmethod GetType

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethod IsDefaultAttribute

When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

System_CAPS_pubmethod System_CAPS_static IsDefined

Determines whether any custom attributes are applied to an assembly. Parameters specify the assembly, and the type of the custom attribute to search for.

System_CAPS_pubmethod System_CAPS_static IsDefined

Determines whether any custom attributes are applied to an assembly. Parameters specify the assembly, the type of the custom attribute to search for, and an ignored search option.

System_CAPS_pubmethod System_CAPS_static IsDefined

Determines whether any custom attributes are applied to a member of a type. Parameters specify the member, and the type of the custom attribute to search for.

System_CAPS_pubmethod System_CAPS_static IsDefined

Determines whether any custom attributes are applied to a member of a type. Parameters specify the member, the type of the custom attribute to search for, and whether to search ancestors of the member.

System_CAPS_pubmethod System_CAPS_static IsDefined

Determines whether any custom attributes of a specified type are applied to a module. Parameters specify the module, and the type of the custom attribute to search for.

System_CAPS_pubmethod System_CAPS_static IsDefined

Determines whether any custom attributes are applied to a module. Parameters specify the module, the type of the custom attribute to search for, and an ignored search option.

System_CAPS_pubmethod System_CAPS_static IsDefined

Determines whether any custom attributes are applied to a method parameter. Parameters specify the method parameter, and the type of the custom attribute to search for.

System_CAPS_pubmethod System_CAPS_static IsDefined

Determines whether any custom attributes are applied to a method parameter. Parameters specify the method parameter, the type of the custom attribute to search for, and whether to search ancestors of the method parameter.

System_CAPS_pubmethod Match

When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

System_CAPS_protmethod MemberwiseClone

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethod ToString

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterface System_CAPS_privmethod _AttributeGetIDsOfNames

Maps a set of names to a corresponding set of dispatch identifiers.

System_CAPS_pubinterface System_CAPS_privmethod _AttributeGetTypeInfo

Retrieves the type information for an object, which can be used to get the type information for an interface.

System_CAPS_pubinterface System_CAPS_privmethod _AttributeGetTypeInfoCount

Retrieves the number of type information interfaces that an object provides (either 0 or 1).

System_CAPS_pubinterface System_CAPS_privmethod _AttributeInvoke

Provides access to properties and methods exposed by an object.

The Attribute class associates predefined system information or user-defined custom information with a target element. A target element can be an assembly, class, constructor, delegate, enum, event, field, interface, method, portable executable file module, parameter, property, return value, struct, or another attribute.

Information provided by an attribute is also known as metadata. Metadata can be examined at run time by your application to control how your program processes data, or before run time by external tools to control how your application itself is processed or maintained. For example, the .NET Framework predefines and uses attribute types to control run-time behavior, and some programming languages use attribute types to represent language features not directly supported by the .NET Framework common type system.

All attribute types derive directly or indirectly from the Attribute class. Attributes can be applied to any target element; multiple attributes can be applied to the same target element; and attributes can be inherited by an element derived from a target element. Use the AttributeTargets class to specify the target element to which the attribute is applied.

The Attribute class provides convenient methods to retrieve and test custom attributes. For more information about using attributes, see Applying Attributes and Extending Metadata Using Attributes.

The following code example demonstrates the usage of Attribute.

using System;
using System.Reflection;

// An enumeration of animals. Start at 1 (0 = uninitialized).
public enum Animal {
    // Pets.
    Dog = 1,
    Cat,
    Bird,
}

// A custom attribute to allow a target to have a pet.
public class AnimalTypeAttribute : Attribute {
    // The constructor is called when the attribute is set.
    public AnimalTypeAttribute(Animal pet) {
        thePet = pet;
    }

    // Keep a variable internally ...
    protected Animal thePet;

    // .. and show a copy to the outside world.
    public Animal Pet {
        get { return thePet; }
        set { thePet = value; }
    }
}

// A test class where each method has its own pet.
class AnimalTypeTestClass {
    [AnimalType(Animal.Dog)]
    public void DogMethod() {}

    [AnimalType(Animal.Cat)]
    public void CatMethod() {}

    [AnimalType(Animal.Bird)]
    public void BirdMethod() {}
}

class DemoClass {
    static void Main(string[] args) {
        AnimalTypeTestClass testClass = new AnimalTypeTestClass();
        Type type = testClass.GetType();
        // Iterate through all the methods of the class.
        foreach(MethodInfo mInfo in type.GetMethods()) {
            // Iterate through all the Attributes for each method.
            foreach (Attribute attr in
                Attribute.GetCustomAttributes(mInfo)) {
                // Check for the AnimalType attribute.
                if (attr.GetType() == typeof(AnimalTypeAttribute))
                    Console.WriteLine(
                        "Method {0} has a pet {1} attribute.",
                        mInfo.Name, ((AnimalTypeAttribute)attr).Pet);
            }

        }
    }
}
/*
 * Output:
 * Method DogMethod has a pet Dog attribute.
 * Method CatMethod has a pet Cat attribute.
 * Method BirdMethod has a pet Bird attribute.
 */
Imports System
Imports System.Reflection

Public Module CustomAttrVB

    ' An enumeration of animals. Start at 1 (0 = uninitialized).
    Public Enum Animal
        ' Pets
        Dog = 1
        Cat
        Bird
    End Enum

    ' Visual Basic requires the AttributeUsage be specified.
    ' A custom attribute to allow a target to have a pet.
    <AttributeUsage(AttributeTargets.Method)> _
    Public Class AnimalTypeAttribute
        Inherits Attribute

        ' The constructor is called when the attribute is set.
        Public Sub New(ByVal animal As Animal)
            Me.thePet = animal
        End Sub

        ' Keep a variable internally ...
        Protected thePet As Animal

        ' .. and show a copy to the outside world.
        Public Property Pet() As Animal
            Get
                Return thePet
            End Get
            Set(ByVal Value As Animal)
                thePet = Value
            End Set
        End Property

    End Class

    ' A test class where each method has its own pet.
    Class AnimalTypeTestClass

        <AnimalType(Animal.Dog)> _
        Public Sub DogMethod()
        End Sub

        <AnimalType(Animal.Cat)> _
        Public Sub CatMethod()
        End Sub

        <AnimalType(Animal.Bird)> _
        Public Sub BirdMethod()
        End Sub
    End Class

    ' The runtime test.
    Sub Main()
        Dim testClass As New AnimalTypeTestClass()
        Dim tcType As Type = testClass.GetType()
        Dim mInfo As MethodInfo
        ' Iterate through all the methods of the class.
        For Each mInfo In tcType.GetMethods()
            Dim attr As Attribute
            ' Iterate through all the attributes of the method.
            For Each attr In Attribute.GetCustomAttributes(mInfo)
                If TypeOf attr Is AnimalTypeAttribute Then
                    Dim attrCustom As AnimalTypeAttribute = _
                        CType(attr, AnimalTypeAttribute)
                    Console.WriteLine("Method {0} has a pet {1} attribute.", _
                         mInfo.Name(), attrCustom.Pet.ToString())
                End If
            Next
        Next
    End Sub
End Module

' Output:
' Method DogMethod has a pet Dog attribute.
' Method CatMethod has a pet Cat attribute.
' Method BirdMethod has a pet Bird attribute.
using namespace System;
using namespace System::Reflection;

// An enumeration of animals. Start at 1 (0 = uninitialized).
public enum class Animal
{
    // Pets.
    Dog = 1,
    Cat, Bird
};

// A custom attribute to allow a target to have a pet.
public ref class AnimalTypeAttribute: public Attribute
{
public:

    // The constructor is called when the attribute is set.
    AnimalTypeAttribute( Animal pet )
    {
        thePet = pet;
    }


protected:

    // Keep a variable internally ...
    Animal thePet;

public:

    property Animal Pet 
    {
        // .. and show a copy to the outside world.
        Animal get()
        {
            return thePet;
        }

        void set( Animal value )
        {
            thePet = value;
        }
    }
};

// A test class where each method has its own pet.
ref class AnimalTypeTestClass
{
public:

    [AnimalType(Animal::Dog)]
    void DogMethod(){}


    [AnimalType(Animal::Cat)]
    void CatMethod(){}

    [AnimalType(Animal::Bird)]
    void BirdMethod(){}

};

int main()
{
    AnimalTypeTestClass^ testClass = gcnew AnimalTypeTestClass;
    Type^ type = testClass->GetType();

    // Iterate through all the methods of the class.
    System::Collections::IEnumerator^ myEnum = 
        type->GetMethods()->GetEnumerator();
    while ( myEnum->MoveNext() )
    {
        MethodInfo^ mInfo = safe_cast<MethodInfo^>(myEnum->Current);

        // Iterate through all the Attributes for each method.
        System::Collections::IEnumerator^ myEnum1 = 
            Attribute::GetCustomAttributes( mInfo )->GetEnumerator();
        while ( myEnum1->MoveNext() )
        {
            Attribute^ attr = safe_cast<Attribute^>(myEnum1->Current);

            // Check for the AnimalType attribute.
            if ( attr->GetType() == AnimalTypeAttribute::typeid )
                Console::WriteLine( "Method {0} has a pet {1} attribute.", 
                mInfo->Name, (dynamic_cast<AnimalTypeAttribute^>(attr))->Pet );
        }
    }
}

/*
 * Output:
 * Method DogMethod has a pet Dog attribute.
 * Method CatMethod has a pet Cat attribute.
 * Method BirdMethod has a pet Bird attribute.
 */
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

This type is thread safe.

Return to top