. Net basic collection Summary

Source: Internet
Author: User

The following are some questions and answers I have collected (the answers may contain some of my own opinions. If there are any mistakes, please point them out ).
1. Three features of object-oriented
Encapsulation, inheritance, and Polymorphism

2. packing and unpacking
Packing: convert value type to reference type
Binning: Convert the reference type to the value type

. In. NET, the data type is divided into value type and reference (not the same as the pointer of C ++) type. Correspondingly, the memory allocation is divided into two methods: Stack, second, heap. Note: it is a managed heap.
The value type is only allocated in the stack.
Allocate memory and managed heap for reference types.
The managed heap corresponds to garbage collection.

3. C # Can I perform direct operations on the memory?
Yes, by adding an unsafe keyword.

4. Differences between structures and classes in C #
The organization and class have a general syntax, and the structure is limited by more than the class. The constructor cannot be declared in the structure. The structure is the value type, and the class is the reference type. Structure instantiation does not use the new keyword. Class can implement interfaces, and the structure is not.

5. Can interfaces inherit interfaces? Can an abstract class implement interfaces? Can an abstract class inherit an object class?
(1) interfaces can inherit interfaces.
(2) abstract classes can implement interfaces
(3) abstract classes can inherit entity classes, but there is a condition that entity classes must have a clear constructor.

6. Can Constructor be inherited? Can it be overwritten )?
The constructor cannot be inherited, so it cannot be overwritten, but can be overloaded ).

7. Differences between Error and Exception
Error indicates that recovery is not a serious problem that is impossible but difficult. For example, memory overflow. It is impossible to expect the program to handle such a situation; exception represents a design or implementation problem. That is to say, it indicates that if the program runs normally, it will never happen.

8. Let's talk about your understanding of delegate in C #.
A delegate is a class that defines the type of a method so that the method can be passed as a parameter of another method. This way, the method is dynamically assigned to the parameter, it can avoid using the If-Else (Switch) statement in a large number in the program, and make the program more scalable. An event is a message mechanism and a delegate without a method body.

9. Reflection and serialization
Reflection: in fact, it is a dynamic operation on the Assembly. The Assembly includes modules, and the module contains types and members. Reflection provides encapsulated assembly, module, and type objects.

We can use reflection to dynamically create instances of the type, bind the type to an existing object, or obtain the type from an existing object, then you can call methods of the type, access fields, and properties.

Serialization: A process of converting an object into a format that is easy to transmit. For example, you can serialize an object and Use HTTP to transmit the object between the client and the server over the Internet.
At the other end, you can use deserialization to reconstruct objects from the stream.

10. C # differences between the value type and the reference type
(1) Value-type data is stored in the memory stack; reference-type data is stored in the memory heap, while memory units only store the address of objects in the heap.
(2) Fast value-type access and slow reference-type access.
(3) The value type indicates the actual data, and the reference type indicates the pointer or reference to the data stored in the memory heap.
(4) The value type inherits from System. ValueType, and the reference type inherits from System. Object.
(5) The stack memory allocation is automatically released, and the stack will be released by GC in. NET.
(6) variables of the value type directly store actual data, while variables of the reference type store the data address, that is, object reference.
Please add ......

11. Talk about your understanding of the three-tier architecture
(1) DAL: data access layer, which directly adds, deletes, modifies, and queries databases.
(2) BLL: the business logic layer that processes data services.
(3) UI: The presentation layer displays processed data to users.
Advantage: embodies the idea of object-oriented programming: High Cohesion, low coupling, and improved scalability.

12. What classes does ado.net use?
SqlConnection, SqlDataAdaptor, DataSet, SqlCommand, SqlDataReader

13. SQL statement implementation paging: query records 31-40 in table T (with auto-incrementing sub-segment ID)
Select * from (select ROW_NUMBER () over (order by ID) as rowNum, * from T) as t where rowNum between 31 and 40

You are welcome to add that, I hope these will be useful to those who need them.

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.