General understanding C #(15. features)

Source: Internet
Author: User
Tags deprecated

15. Features

Both C # and Java compilation Code contain information similar to the field access level. C # extends this capability to compile custom information for any element in the class, such as class, method, field, or even independent parameter, this information can be obtained at runtime. Here is an example of a very simple feature class:

[AuthorAttribute ("Ben Albahari")]

Class

{

[Localizable (true)]

Public String TextFile ://【: Public string Text or public System. String Text. If there is no using System]

{

Get {return text ;}

//...

}

}

Java uses a/***/and @ tag annotation to include additional information about classes and methods. However, this information (except @ deprecated [: Java1.1 and later ]) it is not built into the bytecode. C # With the predefined feature Obsolete, the compiler can warn you to exclude unwanted code (like @ deprecated) and use the Conditional feature to enable Conditional compilation. Microsoft's new XML library uses features to express how fields are serialized into XML, which means that you can easily serialize a class to XML and recreate it again. Another suitable application for features is to create a truly powerful class browser tool. C # The language specification explains in detail how to create and use features.

Related Article

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.