C # Programming Language Study Notes (2)

Source: Internet
Author: User

Chapter 1 Overview
1. struct constructors are invoked with the new operator, but that does not imply that memory is being allocated. instead of dynamically allocating an object and returning a reference to it, a struct constructor simply returns the struct value itself (typically in a temporary location on the stack ), and this value is then copied as necessary.
The constructor of the structure is called using the new operator, but this does not mean the memory allocation ?) Instead of dynamically allocating an object and returning a reference to the object, the constructor of the structure only returns the value of the structure itself (typically, returning a temporary position on the stack ), this value is copied when necessary
2. C # also supports multi-dimen1_arrays. the number of dimensions of an array type, also known as the rank of the array type, is one plus the number of commas written between the square brackets of the array type. the following example allocates a one-dimenwing, a two-dimensional, and a three-dimen1_array.
C # multiple dimensions of array types are supported, also known as arrays. It is the number of commas in the arc of array type plus 1.
The following example allocates a one-dimensional array, a two-dimensional array, and a three-dimensional array.

Int [] A1 =   New   Int [ 10 ];

Int [,] A2 =   New   Int [ 10 , 5 ];

Int [,] A3 =   New   Int [ 10 , 5 , 2 ];

3. the element type of an array can be any type, including an array type. an array with elements of an array type is sometimes called a jarged array because the lengths of the element arrays do not all have to be the same. the following example allocates an array of arrays of Int.
Array elements can be of any type, including the array type. Arrays with elements of the array type are sometimes called a sawing array.
The length does not have to have the same length. The following example is an integer array (as an array element.

Int [] [] =   New   Int [ 3 ] [];

A [ 0 ] =   New   Int [ 10 ];

A [ 1 ] =   New   Int [ 5 ];

A [ 2 ] =   New   Int [ 20 ];

4. C # also supports explicit interface member implementations, using which the class or struct can avoid making the members public. an explicit interface member implementation is written using the fully qualified interface member name. explicit interface members can only be accessed via the interface type.
C # also supports explicit interface member implementation, so that the class and structure can avoid the implementation of the public. Explicit interface member using the full name to reference the name of the interface member.
Explicit interface members can only access through the interface type.
The human class wants to implement some interfaces that contain some methods, such as eating, drinking, and driving Shenzhou 6th, but not everyone has the opportunity to drive Shenzhou 6th. but is there any other interface that can only implement this interface? What should I do? In this case, the explicit interface method can be used. This method can be called only when the human class is converted into an interface ).
5. an Enum type's storage format and range of possible values are determined by its underlying type. the set of values that an Enum type can take on is not limited by its Enum members. in particle, any value of the underlying type of an Enum can be cast to the enum type and is a distinct valid value of that Enum type.
The storage format and value range of the enumeration type are determined by the underlying type. A set of values that can be possessed by the enumeration type)
It is not restricted by enumeration members. In particular, any value of the underlying Enumeration type can be converted into an enumeration type and is a unique valid value of the enumeration type.
6. In order for the default value of an Enum type to be easily available, the literal 0 implicitly converts to any Enum type. Thus, the following is permitted.
To easily use the default values of enumeration types, 0 is implicitly converted to any enumeration type. Therefore, the following statements are allowed.

Season spring =   0 ;

7. A delegate that references an instance method also references a participant object, and when the instance method is invoked through the delegate, that object becomes this in the invocation.
The delegate that references an instance method also references a specific object. When the method is called through this delegate, this object is represented by this)
8. an interesting and useful property of a delegate is that it does not know or care about the class of the method it references; all that matters is that the referenced method has the same parameters and return type as the delegate.
An interesting and useful feature of delegation is the class in which it does not know or cares about the methods it references; all it cares about is that the referenced method has the same parameters and return type as the delegate.
9. types, members, and other entities in a C # program support modifiers that control certainaspects of their behavior. for example, the accessibility of a method is controlled using the public, protected, internal, and private modifiers. C # generalizes this capability such that user-defined types of declarative information can be attached to program entities and retrieved at runtime. programs specify this additional declarative information by defining and using attributes.
The types, members, and other entities in C # can control modifiers in all aspects of their behavior, such as the method visibility publicprotected, internal, and private modifiers. C # promotes this capability, so user-defined declaration information can be attachedProgramThe object is obtained at runtime. The Program specifies the attached declaration information by defining and using attributes.
10. all attribute classes derive from the system. attribute base class provided by. net Framework. if an attribute's name ends in attribute, that part of the name can be omitted when the attribute is referenced
All attribute classes are inherited from the base class "system. Attribute" provided by. NET Framework. If the attribute name ends with "attribute", attributes can be omitted if they are referenced as "attribute.

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.