C #2.0 new feature learning

Source: Internet
Author: User

With the release of Visual Studio 2005, the C # language has been updated to version 2.0. It supports the following new features:

1. Generic
Some generic types are added to this language, so that programmers can achieve high degree of code reuse and achieve higher collection class performance. The generic type only varies with the arity. You can also force a parameter to a specific type.

2 iterator
The iterator makes it easier to define how a foreach loop cyclically accesses the content of a set.

3. Division
The Division type definition allows you to split a single type (such as a class) into multiple files. The Visual Studio designer uses this function to separate the code it generates from the user code.

4. null type
An empty type allows variables to contain undefined values. You can use an empty type when using a database and other data structures that may contain elements that do not contain specific values.

5 anonymous method
Currently, the code block can be passed as a parameter. Code blocks can be used to replace any part of the delegate: no new methods need to be defined.

6. namespace alias qualifier
The namespace alias qualifier (: :) provides more control over access to namespace members. Global: the alias allows access to the root namespace that may be hidden by the entity in the code.

7 static class
To declare classes that contain static methods that cannot be instantiated, static classes are safe and convenient. C #1.2 requires class constructors to be defined as private to prevent classes from being instantiated.

8. External Assembly alias
This extension usage of the extern keyword references different versions of the same component contained in the same assembly.

9 attribute accessors accessibility
You can now define different levels of accessibility for the get and set accessors of the attribute.

10. Co-Variation and inverter in Delegation
The Methods passed to the delegate can be more flexible in the return type and parameters.

11 how to: declare, instantiate, and use a delegate
Method group conversion provides a simpler syntax for declarative delegation.

12 fixed buffer size
In Insecure code blocks, you can now declare a fixed size structure that contains an embedded array.

13 youyuan assembly
An assembly can provide non-public access to other assemblies.

14 inline Warning Control
# The pragma warning command can be used to disable and enable certain compiler warnings.

15 volatile
Now you can apply the volatile keyword to IntPtr and UIntPtr.

 


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.