Some features of c#2.0 to 4.0

Source: Internet
Author: User

List lists for future reference

First, c#2.0

1. Partial class Partial classes

File1.cs

using System;  Public Partial class myclass{    publicvoid  MyMethod1 ()    {        Console.WriteLine (  "MyMethod1 manually written code ");}    }

File2.cs

using System;  Public Partial class myclass{    publicvoid  MyMethod2 ()    {        Console.WriteLine ("  MyMethod2 are usually automatically generated code, such as WebService ");}    }

Compile:

Csc/out: Lib  . dll/t: library File1.cs  file2. /out: App. exe/r: lib. dll App.cs

2. Generics generics

3. Static Class Classes

There can be no instance method in a static class, no instance constructor, and a static constructor, similar to the function of module in the process language

using System;  Public Static class utilityclass{    publicstaticvoid  Foo ()    {        Console.WriteLine ("Hello");    }            }
using System; class app{    staticvoid  Main ()    {        utilityclass.foo ();}    }

You can see that the static class is not an instance constructor.

A non-static class is one that has an instance constructor.

4. Iterator iterators

5. Anomymous Methods anonymous method

6. Nullable Types Nullable type

7.?? Operator

Object NULL  Objectnewreturn//  returns obj

Second, C # 3.0

1. LINQ (language-integrated query)

2. Object initializers Objects initializer

3. Colletion initializers Set initializer

4. Anomymous types Anonymous type (var)

5. Lambda Expressions lambda expression

6. Automatic Properties Auto-complete Property

7. Extension Methods Extension method

Third, C # 4.0

1. Optional parameters and named arguments optional parameters and named parameters

Iv. references

C # 2.0:msdn Wikipedia

C # 3.0:msdn Wikipedia

C # 4.0:msdn Wikipedia What's New on C # 4.0

Not finished

Some features of c#2.0 to 4.0

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.