My understanding of attribute

Source: Internet
Author: User

Attribute is essentially a description of various elements in C #. The types of elements are as follows:

Descriptive elements
Public   Enum Attributetargets
{
All = 16383 ,
Assembly = 1 ,
Module = 2 ,
Class = 4 ,
Struct = 8 ,
Enum = 16 ,
Constructor = 32 ,
Method = 64 ,
Property = 128 ,
Field = 256 ,
Event = 512 ,
Interface = 1024 ,
Parameter = 2048 ,
Delegate = 4096 ,
Returnvalue = 8192
}

Different from other descriptive information, attribute itself is a class, so it can be obtained at runtime. It is a more elegant and consistent method for attaching declarative information to the runtime entity, these attributes can be used to implement further functions during runtime. in attribute. the application (III) (iv) in net programming provides an example of using attribute to call the sqlsever stored procedure, reflecting the advanced usage of attribute. Attribute can also be used for message listening. NET Programming Application (5) (6), there is an example for your reference, but it involves a lot of explanations about the message listening mechanism in C #, which is very confusing, it is difficult to understand.
For the basic usage of attribute, refer to attributes or application of attribute in. NET programming. Attribute is also widely used in nunit. Its intervention makes nunit more intuitive and easier to use than JUnit's naming conventions. The impact of. Net attribute on unit testing is described in detail.

References
Application of attribute in. NET Programming (1) (2) (3) (4) (5) (6)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.