. NET Base Notes

Source: Internet
Author: User
Tags server memory

1. Object-oriented program thinking

Object-oriented is a mechanism of program development, which is characterized by encapsulation, inheritance and polymorphism. When writing a program in an object-oriented manner, a complex project is abstracted into a model that works with multiple objects, and then a model structure is written that declares or implements the members of the type, which describes the characteristics and behavior of the object, writes different types to resolve or accomplishes different functions, and solves the actual problem through the instance of the class in the program.

2. Class and Object differences

A class is a kind of thing, an object that refers to an entity that belongs to this kind of thing;

The class defines the relevant data and methods of the object, and the class generates the object through the constructor, which implements the definition of the class and has specific data.

3. Modifier function

The private-owning class can be accessed internally, and some cases can be read or modified by a get or set.

Internal access to the class and subclass that the protected belongs to.

Internal internal access to the same assembly.

Public access permissions, unrestricted.

4. Sealed modifier

Used to decorate classes, instance methods, and properties, when a class is decorated, the class cannot be inherited, so it is also known as a sealed class.

Abstract classes must be inherited to make sense, so they cannot coexist.

5. Override and Overload

Overload method names are the same, function signatures are different, multiple overload can be adapted to different needs.

Override to extend or overwrite a base class, the signature must be consistent.

6. Interfaces and abstract classes

Neither of them can be instantiated, and the parts that are not implemented are implemented by derived classes, and abstract classes can only derive classes, and interfaces derive classes and structs.

Derived classes of abstract classes can also be said to be restricted classes, that is, abstract members are not necessarily implemented in derived classes.

An interface requires a derived class or struct to fully implement its members.

An abstract class can contain a member that has already been implemented and can contain fields;

The interface contains only the members that are not implemented, and cannot contain fields.

A class can inherit only one abstract class, but may inherit multiple interfaces.

7. This and base

This is used to refer to the current instance of the class, and base is used for derived classes to access base class members.

8. Outlining assemblies and application domains

 Assemblies are used to solve DLL-related problems, self-describing installation units, logical units, not a file.

An assembly can make multiple files that contain metadata, or it can be a DLL or EXE execution file.

Dynamic assemblies are in memory, not storage files.

The application domain is. The program boundaries in net.

9,. NET Program compilation process

  Written in a variety of high-level languages, such as C#,VB, and eventually compiled into a consistent intermediate language (IL) by the respective compiler. Then the CLR (when the common language is in progress) provides a running environment that compiles the intermediate language into machine code for CPU execution.

Intermediate languages are compiled in real time, also called JIT compilation. This method only compiles the code part of the call, the compiled part is stored in memory, the next execution does not need to be compiled again, when exiting the program, the compiled part of the code will be cleared.

10,. NET Program Intermediate language (IL), also known as managed code, has the advantages of platform independence, JIT performance optimization, and language interoperability.

11. Using and namespaces

The using can be used to reference namespaces, automatically freeing resources used by objects, and adding aliases.

Reference namespaces:

Using System;

Automatically dispose of objects using resources

using (SqlConnection con=new SqlConnection (CONNTSR)) {

Con. Open ();

}

Add Alias

Using S=system;

namespaces reflect logical relationships in a program, and effectively avoid class name collisions. Represents the logical organization of the various classes, regardless of the physical organization mode.

You can use the namespace keyword to customize the namespace.

12. Value types and reference types

A value type contains data, and the reference type contains only the memory address of the data.

A value type is purged from memory as long as it leaves its defined scope, and reference-type reference objects persist in the managed heap. NET collector will automatically destroy it.

13. Structure and Class

A struct type is a data wrapper for a value type that can be used to encapsulate a simpler data structure and share most of the syntax with the class.

Structs do not support inheritance, and all structures inherit directly from System.ValueType.

Structs cannot declare parameterless constructors and destructors, because the compiler provides a default constructor and initializes the members. You can declare a constructor with parameters.

The static field of the structure can be assigned the initial value directly, and the instance member is not allowed.

Because the struct type is a value type, all instantiations can not use the new operator. The new operation of the struct does not perform an allocation memory operation, only initialization is performed.

14, stacks and heaps

Stack refers to the stack, which refers to the managed heap, which can be used to store value type data for non-instance members, as well as variables of reference types, while the managed heap can be used to store data and related information for reference type instances.

15, entrusted delegate--

Can be understood as a reference to a function, the event is a special delegate.

16, page Transfer value method

QueryString use simple, but lack of security, values are exposed to the URL, Chinese need to transcode.

Session is simple to use, can pass simple data types and objects, the data size is unlimited, consumes more server resources.

Cookies are simple to use, and cookies are used to keep the user state in a cross-page form, but they are easily considered to collect user privacy.

Server.Transfer directly in the server end multiplicity oriented, easy to use, reduce the client to server requests, can pass data types and control values, but because the URL address is not changed, if the source page and the target page is not in the same directory or sub-directory, using a relative path to the picture, hyperlinks will be wrong point.

Application is easy to use, consumes less server resources, has unlimited data size, can pass data and objects, but is easily manipulated as a global variable.

Cache full page cache, easy to implement, consume server memory, fragment cache, save memory, but realize trouble, application cache, not restrict cache webpage, but implement complex.

17. Common Call WebService method

The WSDL.exe command-line tool generates the proxy class and then references the class file in the code

Add a reference to a. NET program, add a service reference.

Get,post of the HTTP protocol

HttpClient Call

18, String str=null, does not allocate memory space, string str= "", allocates the memory space with the length of the empty string.

19. Threads and processes

Both thread and process define some kind of boundary.

The thread defines the bounds of the code execution stack and execution context.

Process defines the boundaries of an application, and the code and data spaces cannot be shared between different processes.

A process can contain multiple threads.

The maximum amount of memory that a single process can access is 1/2 of the maximum virtual RAM.

20. Windows Services

Applications running under the background specified user (System), no standard UI interface. Created at the start of the service and destroyed at the end of the service.

21. GAC

The global application set cache, which resolves several programs that share an assembly, does not have to copy the shared assembly to the application directory.

. NET program is loaded with the first view of the GAC, there is a direct use, no go to the application directory to find.

22, ADO. NET five major objects

Command

Connection

DataReader

DataSet

DataAdapter

23. How many processes can the TCP/IP port listen to

Can listen for multiple processes (port multiplexing).

Port Multiplexing Code:

1Socket soc1=NewSocket (addressfamily.internetwork,sockettype.stream,protocoltype.tcp);2Soc1. Bind (NewIPEndPoint (Ipaddress.parse ("127.0.0.1"),8235));3Soc1.listen (Ten);4Soc2. SetSocketOption (Socketoptionlevel.socket,socketoptionname.reuseaddress,true);5Soc2. Bind (NewIPEndPoint (Ipaddress.parse ("127.0.0.1"),8235));6Soc2.listen (Ten);7Console.read ();

24. asmx's XML Web service and soap's. Net Remoting

The Web service uses the messaging mechanism, remoting with RPC. Web service can be used on different platforms, remoting only for. Net.

Remoting efficiency is higher than XML Web Service.

----NOT to be continued

  

  

  

. NET Base Notes

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.