. NET Foundation Collection Summary

Source: Internet
Author: User
Tags abstract constructor garbage collection reflection serialization
The recent interview let me know the importance of basic knowledge, and I also every day on the Internet to find some basic questions to see. In fact, the interview is nothing but a number of theoretical basis, only the basis of clearance, will be asked technical questions, so the first must play well

Here are some of the questions and answers I've collected (the answer may contain some of my own insights, please point out if there are errors).
1. Object-oriented three major characteristics
encapsulation, inheritance, polymorphism

2. Box and unboxing
Boxing: Value type conversion to reference type
Unboxing: Conversion of reference type to value type

. NET, the data types are divided into value types and references (not equivalent to C + + pointers) types, and in this case, memory allocation is divided into two ways, one for the stack, two for the heap, note: the managed heap.
Value types are only allocated on the stack.
The reference type allocates memory to the managed heap.
The managed heap corresponds to garbage collection.

3.c# can I do a direct operation on memory?
it can be done by adding a unsafe keyword.

The difference between structure and class in 4.c#
institutions and classes have a general syntax, and structures are subject to more restrictions than classes. Structs cannot declare constructors. Structs are value types, and classes are reference types. The instantiation of a struct can be without the use of the new keyword. Class can implement interfaces, and structs cannot.

5. Interface can inherit interface? Can an abstract class implement an interface? Can an abstract class inherit an entity class?
(1) interface can inherit interface
(2) Abstract class can implement interface
(3) An abstract class can inherit an entity class, but with one condition, the entity class must have a clear method of constructing it.

6. Can the constructor constructor be inherited? can be overridden (Override)?
constructors cannot be inherited, so they cannot be overridden, but can be overloaded (overload).

The difference between 7.Error and exception
error indicates that recovery is not an impossible but difficult situation with a serious problem. For example, memory overflow. It is impossible to expect a program to handle such a situation; exception represents a design or implementation problem. That is, it means that if the program is working correctly, it will never happen.

8. Talk about your understanding of the delegates in C #
a delegate is a class that defines the type of a method so that it can be passed as a parameter to another method, which dynamically assigns the method to the parameter, avoiding the use of if-else (Switch) statements in the program, and making the program more extensible. An event is a message mechanism, a delegate that does not take a method body.

9. Brief description of reflection and serialization
Reflection: In fact, in the dynamic operation of the Assembly, the Assembly includes the module, and the module contains the type, and the type contains the members. Reflection provides an object that encapsulates an assembly, module, and type.

We can use reflection to dynamically create an instance of a type, bind a type to an existing object, or get a type from an existing object, and then call the type's methods or access the fields and properties.

Serialization: A simple understanding of the process of converting an object into an easily transmitted format. For example, you can serialize an object and then use HTTP over the Internet to transfer the object between the client and server side.
At the other end, you can use deserialization to reconstruct the object from that stream.

Difference between a value type and a reference type in 10.c#
(1) Data of value type is stored in stacks of memory; the data of the reference type is stored in the heap of memory, while the address of the object in the heap is stored in the memory cell.
(2) Value type access speed is fast, reference type access speed is slow.
(3) The value type represents the actual data, and the reference type represents a pointer or reference to the data stored in the memory heap
(4) The value type inherits from the System.ValueType, and the reference type inherits from the System.Object
(5) The stack of memory allocation is automatically released; NET will have a GC to release the
(6) A variable of a value type directly holds the actual data, while a variable of the reference type holds the address of the data, which is the reference of the object.
Welcome to add ...

11. What do you know about the three-tier architecture?
(1) DAL: Data access layer, directly to the database of the increase and deletion check.
(2) BLL: Business logic Layer, the processing of data services.
(3) UI: The performance layer, the processing of the data presented to the user.
Advantages: Embody the idea of object-oriented programming: Cohesion well-structured classes low coupling, improve extensibility.

Which classes are used by ado.net?
SqlConnection, Sqldataadaptor, DataSet, SqlCommand, SqlDataReader

13.SQL Statement Implementation paging: Querying 第31-40条 records in table T (with self-increasing sub-segment ID)
SELECT * FROM (select Row_number () "Over" (order by ID) as rownum,* from T) as T where rownum between-40

Welcome you to add, hope that these people need a little use.

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.