C # -- Review

Source: Internet
Author: User

08-08-27
Keyword Params. It can be used to pass parameters to the method with an indefinite number, and array packaging is not required in advance.However, there are many restrictions and inconveniences. The most important thing is to add the Params parameter as the last one. I remember that there was such a thing that should be used. Of course, the magic pens used for this Params should be the methods of the console. Write () family.
Abstract methods cannot be declared as non-abstract classes. All the Members in the interface are public and abstract by default,However, an error is reported if the method signature cannot be displayed and written.. (These two points are mainly aimed at the differences between C ++ and Java. In C ++, any abstract method is an abstract class, in Java, although the default values are public and abstract, you can write them as well)

 

08-08-29
the value type can be = compared with null, but all values are false.
C # itself does not have a separate runtime class library. as I said, C # not exclusive ,. net Framework is the runtime class library of C.
in C # command line, the command for compiling a class library is CSC/T: library file name (/T is the target type: EXE, winexe, library, Moudle)
compile the EXE command of a using class library, CSC/R :**. DLL file name (/R references a Program set)
An assembly is an EXE or DLL that contains the intermediate language and metadata ). Before executing the Assembly, clr jit converts the IL Code in the Assembly to the local code.
variables of the value type directly contain their data, variables of the reference type store references to their data.

What do you know about the types we control?
Value Type and reference type: the value type is classified into simple type, enumeration type and structure type, reference type and classification type, interface type array type and delegate type.
The structure does not support user-specified inheritance.
The delegate type indicates the reference of the method through the parameter list and return type. The delegate processes the method as an object, so that it can be assigned to a parameter and passed as a parameter. Delegation is object-oriented and type-safe.
Packing and unpacking:
C # all types of base classes are objects,In order to operate the value type like the reference type, the conversion between the value type and the object is packed and unpacked. However, a requirement for unpacking is that the object must be packed, otherwise an error occurs during running.

C # code runs in a safe, managed environment. Every memory loaction is checked, including array indexes.
The runtime generates a test of the actual Array bounds before accessing each particle array element.

About foreach

The foreach generates the best iteration Code for any collection you hava.
Foreach now generates different il for arrays than other collections. The array version does not use the ienumerator interface, which wowould require boxing and unboxing.

About Enum
When you create your own values for an Enum, make sure that 0 is one of them.
The system initializes all instances of value types to 0. there is no way to prevent users from creating instances of value types that are all 0s. if possible, make the all 0 case the natural default. as a special case, enums used as flags ensure that 0 is the absence of all flags.

08-09-01
The checked and unchecked statements are used to control integer arithmetic operations and the overflow check context of the conversion.
The lock statement is used to obtain the mutex lock of a given object, execute a statement, and then release the lock.
The Using statement is used to obtain a resource, execute a statement, and then release the resource.
The array has a Length attribute.
A class is a data structure that combines state and behavior in a unit.
Class Members are either static or instance members. Static members belong to the class, and instance members belong to the object.
The value assignment to the readonly field can only appear as part of the field declaration, or be performed in the instance constructor or static constructor of the same class.
The instance constructor is a member of the Operation required to initialize the class instance. The static constructor is a member of the Operation required to initialize the class itself when the class is loaded for the first time.
For a small data structure, you can use a structure rather than a class to save a lot of memory allocation when the application is running.
The constructor of the structure is called through the new operator, but this does not mean that the memory will be allocated. The constructor of a structure does not dynamically allocate an object and return a reference to its value, but simply returns the structure value itself (usually in the temporary position of the stack ), then copy the value as needed.
08-09-02
When an application is running, a new application domain is created as a container of the application state, allowing applications to be isolated from each other. The application domain acts as the container and boundary of the types defined in the application and its class libraries.

 

---- by Qian bingnian @ yitian studio

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.