1.1 .NET platform base Microsoft's .NET platform core is a series of new collections, called .NET Framework, which usually view Framework is .NET Framework. This frameset provides a platform that can quickly develop Windows-based programs or quickly develop web applications. .NET Framework provides two main components, universal language run library (CLR) and framework libraries (FCL). Like many new technologies, there are many terms and abbreviations to understand, so we will in the next part Describe and explain many terms and abbreviations in Framework. 1.1.1 Public Language Runtime (CLR) CLR is the execution environment of the code written by the .NET Framework. The CLR manages the execution of .NET code, including memory allocation and garbage recycling (avoiding memory leak issues), security (including different trust applications), thread management, strong type, and other tasks . As long as the .NET supported language, CLR can run, so it is not necessary to match a separate running library for each language. Each .NET language is compiled (for example, Visual Basic .NET compiler) into an intermediate language (IL). In runtime, the intermediate language is compiled (JIT) cost machine in the middle language (JIT) cost machine (CLR running machine) This compilation method provides a flexible approach that can still keep the speed executed when using different language writing code. 1.1.2 .NET Framework class library (FCL) FCL is a series of reusable object-oriented classes that provide basic platform features, from the access database class ADO.NET, the class to the file system module class (including files, Catalog and flow and other classes to allow us to easily implement DNS parsing, WHOIS search, and class libraries for classes of other network-related features. Developers can directly use these base classes or inherit these classes to implement some custom functions. FCL is of course also encapsulated all ASP.NET classes. This includes all the features of all ASP internal objects, in addition to this, there is more features, like providing a rich cache output and data engine, as well as an ASP.NET server component model. These functional modules make ASP.NET easy to develop as controls, which is very familiar with VB developers. In addition to providing Web applications, FCL also provides development of console applications, Windows applications, Windows NT or Windows 2000 services. 1.1.3 Public Type System (CTS) CTS describes the collection of data types supported by the CLR, which includes both value types (including simple data types, like Byte, INT16, and Boolean et al), including reference types (including Arrays) , classes, objects, and string types). The value type is stored directly in memory. You can use the name to get its value, see one of the following code: 'VB.NET DIM Myfloat as single myfloat = 3.1415 // C # float myfloat; myfloat = 3.1415; In addition to these The data type built, the value type also includes the user-defined data type (from the type of system.valueType inheritance) such as an enumeration type. The reference type is a reference to a value address, not a direct storage value.
Typically, the value is stored as part of the definition class and is referenced by an instance of a class member, as shown below: 'VB.NET' Definition class class myfloatclass public myfloat as single End class' creates an instance of the class and assigns DIM MyInstance As new myFloatClass () myInstance.myFloat = 3.1415 // C # // definition of class class myFloatClass {float myFloat;} // create an instance of the class and assigning myFloatClass myInstance = new myFloatClass (); myFloatClass.myFloat = 3.1415;
Individual language compilers may use their own terms to supplement the type. For example, .NET uses INT32 to represent 32-bit integers, with Integer in Visual Basic .NET, in C # is represented in c #. But in-internal implementation, Visual Basic's Interger and C # int 3 are all .NET's int32 type implementation. 1.1.3.1 Boxing and Unboxing Value Types and reference types of mutual conversions are done by a packing and unpacking process. Packing refers to implicitly converting a value type, such as a C # int type to a reference type (usually object). When the conversion occurs, an instance of an object type is created, which is only copied to this object instance (in this box). The unpacking is expressed as a reference type to a specified value type. The following code demonstrates the box and unbox: // c # int myint = 123; // Declare an int type value type variable, and assigns 123 Object myobj = myint; // myint Packing into myobj int myotherint = (int) MyObject; // Unpacking MyObject to Myotherint1.1.4 Public Language Architecture (CLI) CLI is a subset of the CLR, that is, the part of the .NET finally manages the operating environment of the application that compiles into MSIL code. . In the CLR structure diagram, the CLI is located in the lower half, mainly including the Class Loader, a real-time compiler, and a garbage collector of a runtime environment (Garbage Collector). The CLI is the soul of .NET and CLR, the CLI provides a running environment for the IL code, and you can use the code written in any language to run to the MSIL code through its specific compiler, or even write MSIL code yourself. The CLI is running. As you know, the European Computer Manufacturers Association (ECMA) has been approved on October 13, 2001 to become a newly born computer industry standard on October 13, 2001. At the same time, ISO ISOs also agreed to the standard to enter the approval phase of the organization. Also, as the core part of .NET and CLR, CLI and C # also obtained ECMA approval (ECMA-335). With two standards of C # and CLI, you can write it yourself to run the .NET platform (as long as you are willing) you can run on any operating system. As mentioned earlier, the famous mono project is so dry, the Mono project includes three core parts: a C # language compiler, a CLI and a class library. In the world of Java, this work is done by Sun Company, and Sun has developed a corresponding Java virtual machine for different operating systems to allow a application-developed application in different operating systems, but so far. I have never heard of Microsoft, which is intended in this area (providing users with a non-Windows system .NET platform). About CLI can refer to the following website: http://msdn.microsoft.com/library/en-us/dndotNet/html/msharsourceCli2.asp http://www.go-mono.org/1.1.5 Public Language Norm (CLS CLS is a subset of the types supported by the CLR, such as a series of programming languages and compilers must follow the rules. The purpose of CLS is to provide rich interoperability between .NET language, including classes written from a .NET language to another .NET language written subclass, and can be crossed. The rule defined by the CLS can only be applied to the public characteristics of the class.
For example, an implementation of the class can use a CLS incompatible type (such as unsigned integer), but as long as the CLS compatible type member is public, this class still can use the interoperability of CLS. 1.1.6 Class (CLASS) Class is not a special term for the .NET platform, but the term may be a bit unfamiliar with the ASP developers. Class is an abstract definition of an object. The definition of how to instantiate specific objects at runtime, such as public attributes and methods, and all internal storage structures. Developers can create a class instance with the New keyword when running, as shown below: // At the beginning of the .NET's StreamReader SR; Sr = new system.io.streamReader ("C:) in C #. //Test.txt "); string line; while (sr.peek ()! = -1) {line = sr.readline (); response.write (server.htmlencode (line) " ") } Note: In C #, the New keyword is used to initialize the class, and the new keyword is used in Visual Basic .NET, but Visual Basic .NET is unoccupied, and C # is sensitive, Therefore, pay attention to case in two language switches. 1.1.7 Namespaces Name Space is a key section of .NET Framework, providing a pre-installed class and a custom class scope. In order to put a series of collections into a collection, use the following definition: // C # namespace mynamespace {class myclass {// class implementation code} 'VB.NET NAMESPACE MYNAMESPACE CLASS MyCls' implementation code END CLASS END name space may also be nested namespace: achieved Code End class namespace mySecondNamespace 'VB.NET namespace myFirstNamespace Public class myCls' class Public class myCls 'End code that implements the class class Public class myCls2' class code class End End End namespace namespace This code is completely legal because we declare the second MyCls in MysecondNameSpace in nested namespace. If we declare the two identical identity names in the same name space, you get a compilation error, and the report has a name conflict because the name inside each name space must be unique.
We just use the class definition, we use the following code: 'VB.NET Imports System Imports myFirstNamespace Imports myFirstNamespace.mySecondNamespace Module namespaces_client_vb Sub Main () Dim newClass As New myFirstNamespace.myCls Dim newClass2 As New myCls2 Console.WriteLine ( "Object CREATION SUCCEED! ") End Sub End Module We use the imports keyword in Visual Basic .NET in order to explicitly use the namespace when using the member under this name space. However, if we want to use mycls at the same time while MyfirstnameSpace and MySecondNamespace, we must use a full path name. The lowermost class name space can be used directly introduced into the class name, the following C # code: using System; using myFirstNamespace; using myFirstNamespace.mySecondNamespace; class namespaces_client {public static void Main () {myFirstNamespace.myCls newClass = new myFirstNamespace.myCls ( ); Mycls2 newclass2 = new mycls2 (); console.writeline ("Object Creation Succeed!");}} C # uses the USING keyword to introduce the namespace. Note the above two examples, in addition to introducing our own defined namespace, we also introduced the SYSTEM name space, this name space allows us to use the COSOLE class, we do not need to explicitly call the System.Console class. 1.1.8 Assemblies, like the managed DLL, the assembly is the basic unit deployed by the .NET platform. The .NET platform itself consists of a series of assemblies, including mscorlib.dll and others. The boundaries of these assemblies also provide versions and security information. A program set contains an intermediate language generated by a particular compiler, a program list (including information of the assembly), type metadata, and resources. We will discuss intermediate languages, program lists, and metadata in later. The assembly can be either privately (placed in a specific directory, in the ASP.NET, in the application / bin directory), can also share. Shared assembly is stored in a place called global assembly cache (GAC). The assembly installed in the GAC must be renamed, that is, there must be an associated encryption key. Strong naming can be done by Visual Studio .NET or using the sn.exe tool provided by the .NET Framework SDK to generate a pair of program set key values, then use the Al.exe tool to generate a signature set based on the generated key value. 1.1.9 Intermediate Language IL, also called MSIL (Microsoft Intermediate Language), is an executable code that does not depend on the processor. IL is a part of assembly language, but does not rely on any CPU; but it relies on CLR. IL is a CLR-oriented code generated by a compiler of various languages.