In-depth understanding of C # 2nd

Source: Internet
Author: User

(P13) to a large extent, C #2 is more like repairing and completing various shortcomings of C #1, so it is not a blockbuster. In C #3, almost all the features are used to build LINQ, and the results are also very special;

(P24)
In order for the delegate to do something, four conditions must be met:
-- Declare the delegate type;
-- A method must contain the code to be executed;
-- A delegate instance must be created;
-- The instance must be called (invoke;

(P30) the event is not a delegated instance-it is just a pair of add/remove methods (similar to the attribute value method/value assignment method );

(P37)

The array type is a reference type, even if the element type is a value type (So int [] is still a reference type, even if int is a value type );

The interface type (declared by interface) is the reference type, but can be implemented by the value type;

(SpO2)

The value of a variable is stored in its declared position. The value of a local variable is always stored in the stack, and the value of an instance variable is always stored in the storage of the Instance itself. Reference Type instances (objects) are always stored in heap, and static variables are also;

Value types cannot be derived from other types;

(P40) when you call the GetType () method of the type variable value, it is always accompanied by the packing process because it cannot be overloaded. If you are dealing with unboxed variables, you should already know the specific type, so use typeof instead;

(P41)

Objects of the reference type are always on the stack. Values of the value type may be on the stack or stack, depending on the context;

When the reference type is used as a method parameter, the parameter is passed in the "value transfer" method by default-but the value itself is a reference;

A value of the value type is boxed when it needs to reference the type; unpacking is the opposite process;

(P47) the so-called "function-based" programming style is to encourage developers to use delegation more. The introduction of anonymous methods and Lambda expressions makes delegation easy to create and use;

(P48) Basically, generics implement the "parameterization" of types and methods, just as in common method calls, parameters are often used to tell them what values to use. Similarly, generic types and methods allow parameters to tell them what type to use;

(P52) the unbound generic type is the blueprint of the constructed type, and the constructed type is the blueprint of the actual object, because of this relationship, so there is an additional abstraction layer;

(P53) In fact, the C # Language Specification has been clearly stated. For any type that is not an "open type", it is a "closed type ". All types that involve type parameters are "Open Type ";

(P55)

T is the type parameter used within the scope of the class;

The type parameter followed by the method name in angle brackets is the type parameter of the generic method;

(P57)

A method cannot be generic, which means it must be a part of the generic type;

When calling a generic method, use the same syntax as previously seen to specify the parameter type;

(P58)

Constraints should be placed at the end of the generic method or generic type declaration, and introduced by the context keyword where;

The reference type constraint is T: class must be the first constraint specified for the type parameter;

The Type constraint of the constructor is T: new (), which must be the last constraint of all type parameters;

(P62)

The constraint list of each type of parameter must be introduced with a where statement;

Type inference is only applicable to generic methods and not to generic types;

(P74) when implementing the methods or attributes specified by an interface, the additional interface name is called "Explicit interface implementation" as the prefix ";

(P78) array covariance-an array of the reference type can be regarded as an array of its base type or an array of any interfaces It implements;

(P141) in conventional methods, the return Statement has two functions: first, providing the return value to the caller; second, terminating the execution of the method and executing the appropriate finally code block upon exit;

(P194)

The basic function of LINQ is to create an Operation pipeline and any status required for these operations;

LINQ to Objects processes data sequences in the same process;

(P196)

The most lengthy form of Lambda expressions is -- (explicit type parameter list) =>{ statement}

Lanhang expression quick Syntax:
(Explicit parameter list) => Expression
(Implicit type parameter list) => Expression
Parameter Name => Expression

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.