What's new in c # 2.0

xiaoxiao2021-03-06  117

With The Release of Visual Studio 2005, The C # Language Has Been Updated to Version 2.0.

Generics (C #)

Generic types are added to the language to enable programmers to achieve a high level of code reuse and enhanced performance for collection classes. Generic types can differ only by arity. Parameters can also be forced to be specific types. See

Generic Type Parameters (C #)

For more information.

Iterators (C #)

Iterators Make It Easier to Dictate How A

Foreach Loop Will Iterage Over a Collection's Contents.

Partial Class Definitions (C #)

Partial Type Definitions Allow A Single Type, Such As a Class, To BE Split Into Multiple Files. The Visual Studio Designer Uses this feature to sedate it. generated code from user code.

Nullable Types (C #)

NULLABLE TYES ALOW A Variable to Contain A Value That Undefined. Nullable Types Areful WHEN Working with Databases and Other Data Structures That May Contain Elements That Contain No Specific Values.

Anonymous methods

IT is now Possible to Pass A Block of Code As a parameter. Anywhere a delegate is expected, a code block can be used instead: There is no need to define a new method.

:: Operator

The namespace alias qualifier

: :) Provides more control over accepting namespace members. The

How to: Use The Global Namespace Qualifier (C #)

Alias ​​allows access the root namespace That May be hidden by an entity in your code.

Static Classes

Static classes are a safe and convenient way of declaring a class containing static methods that can not be instantiated. In C # v1.2 you would have defined the class constructor as private to prevent the class being instantiated.

Extern (C # Programmer's Reference)

.

Accessor Accessibility

IT is now Possible to Define Different Levels of Accessibility for THE

Get and

Set Accessors on Properties.

Covariance and Contravariance (C #)

The Method Passed to a Delegate May Now Have Greater Flexibility In Its Return Type and parameters.

Fixed Size Buffers (C)

IN AN UNSAFE CODE BLOCK, It's now Possible To Declare Fixed-Size Structures with Embedded Arrays.

Friend assembly (C #)

Assemblies CAN Provide Access To Non-Public Types To other assembly.

#pragma Warning

The #pragma Warning Directive May Be used to disable and enable Certain Compiler Warnings.

转载请注明原文地址:https://www.9cbs.com/read-125778.html

New Post(0)