It took me some time to repeat "C # standard version 3.0" over the past few days and browse it. Now time is very important for me and I can only pass it over, therefore, I have sacrificed some specific learning content. It is recommended that beginners read each sentence in detail and thoroughly understand the C # syntax.
This series of e-book resources can be found in my CSDN download channel: http://download.csdn.net/source/1792062.
Standard 3.0 is actually just based on version 1.2. It adds the 2.0 concept and some new concepts of version 3.0. As with version 2.0, it is not an independent introduction of new content. This is a failure of version 3.0. On the one hand, it does not detail the newly added content. On the other hand, the concepts in section 2.0 are not described in detail. The content is complete, but the description is not so clear. Therefore, it is recommended that you carefully read the 1.2 edition specifications, and then carefully read the 2.0 edition specifications. In the end, the 3.0 edition is a look at the new concepts in detail, it is enough to leave some impressions on other content, so you don't have to be so careful and it is a waste of time.
When I passed version 3.0, I had some additional ideas and added some basic concepts. First of all, there are several chapters on this specification that interpret the lexical and grammar of the C # language. This can be used as a reference for developing a new language, understand the rules defined by the language. Then, through this specification, You can implement the C # code generator and tools such as code line statistics, because it describes the content edited by the Code, for example, how to judge the end of a row (using a line feed identifier. There are many other things for you to understand.
Some of the following content is supplemented:
The structure is not described so clearly. Here we will add a deeper understanding of this concept. The structure is a value type, so the structure cannot be inherited, but the structure can implement interfaces. It sounds simple, but think about it. The structure is a value type. The value type can be used to reference the type method. It is a bit strange. The value type is generally only used to save data. We know that the final base class of any type is an object. Because the object is a reference type, the value type is actually inherited from System. ValueType. Why is the value type different from the reference type, but the data structure is different, and the storage format is different when the memory is allocated. One is on the stack and the other is on the managed stack. This is not suitable for implementing interfaces in the structure. Structure is stored on the stack. If you call a structure method, but when you call an explicit implementation method of an interface, you need to copy a copy of the structure to act as the interface object, which consumes system resources. Generally, it is not recommended that the structure be used to handle explicit calls to interfaces. It does not seem very useful for the structure, because the object is a data structure of a custom class type.
Here, by the way, we design objects. objects are defined as class instances, that is, all new objects are called objects. But the specification says, "the C # type system is uniform, so any type of value can be processed by object ." "Value Type values are processed by objects by packing and unboxing (section 4.3 ". This is a self-contradictory statement. The value type data is also an object, for example, int I = 0; in fact, it is short for int I = new int (); I = 0, because of the language relationship, the storage structure of this value type is not treated as an object. Here I. ToString () and so on are inherited from the object method. C # Is Object-Oriented. All types are objects and value types should not be divided out. For example, an integer is a numerical value, but abstract. It is a number and a number is an object. This is incorrect in the specification.
For the interface, I would like to add it here. Interface implementation is classified into implicit and explicit. The implicit implementation of the interface can be called directly by the implemented object or structure. However, the interface display implementation can only be called by the interface instance. For example:
Interface IT
{
Void Test ();
}
Class CClass1: IT
{
Int I;
// Implement the interface implicitly. The interface method must be public.
Public void Test ()
{
Return;
}
}
Class CClass2: IT
{
Int I;
// Explicitly implement the interface. The interface method must be public
Void IT. Test ()
{
Return;
}
}
Void Main ()
{
CClass1 c1 = new CClass1 ();
C1.Test ();
Ccass2 c2 = new ccass2 ();
C2.Test (); // Error
IT it = (IT) c2; // explicitly converted to interface IT, or directly IT = c2; implicit conversion
It. Test (); // correct
}
The interface is also a reference type, so the interface instance looks a bit strange (object it), because it is not a specific object that contains the implementation method, in fact, the instance object of this interface, only instance c2 that implements the object of this interface, which is also a multi-state content. Therefore, the above definition of CClass2 can be:
Class CClass2: IT
{
Int I;
// Explicitly implement the interface. The interface method must be public
Void IT. Test ()
{
Return;
}
// A Test method of the class itself
Public void Test ()
{
}
}
The above classes can be replaced by structures, which are also applicable. In fact, the above is the interface ing problem. This concept should also be clarified.
The above content is actually a supplement to the Basic concepts. I have repeatedly stressed the importance of the concept and the concept is unclear. When coding, the editor can be used to correct it, however, it has a great impact on the architecture design. If an error occurs, modifications will affect a batch of code. Therefore, if you want to learn C #, you should focus on the C # specification, clarify the concept, and then study the advanced skills and applications. Although the C # specification written by Microsoft has many self-contradictions, you should not remember it when looking at the specification, but understand it to be profound, it is not misleading.
It's no longer a nonsense. It's another weekend. It's so fast. Have a good weekend ''''''