Home > Backend Development > C#.Net Tutorial > C#.net common knowledge points that are often confused

C#.net common knowledge points that are often confused

巴扎黑
Release: 2016-12-19 16:44:10
Original
1784 people have browsed it

1. Could you please tell me the difference between classes and structures in .NET?
Answer: Structures and classes have a general syntax, but structures have more restrictions than classes. A structure cannot declare a default constructor, because a copy of the structure is created and destroyed by the compiler, so there is no need for a default constructor and destructor. Structures are value types, so changes to structure variables will not affect their original values, while classes are application types, and changing the values ​​of their variables will change their original values. Use the Struck keyword to declare a structure and the class keyword to declare a class. When passing a structure to a method, it is passed by value, not by reference. Unlike classes, structures can be instantiated without using the New keyword. Classes can implement interfaces.
2. What are the necessary conditions for deadlock? How to overcome it?
Answer: The system has insufficient resources, the order of advancing processes is inappropriate, and resources are allocated improperly. A resource can only be used by one process at a time. When a resource requests a resource, the resource is blocked at this time, and the obtained resource cannot be used. When a process obtains a resource, it cannot be forcibly deprived of it before it is used up.
3. Can interfaces inherit interfaces? Can an abstract class implement an interface? Can an abstract class inherit from an entity class?
Answer: Interfaces can inherit interfaces, abstract classes can implement interfaces, and abstract classes can inherit entity classes, but there is a condition. The condition is that the entity class must have a clear constructor.
4. Can Constructor be inherited? Can it be Overrided?
Answer: Constructor cannot be inherited, so it cannot be overriding (Overriding), but it can be overloaded (Overloading).
5. Can the String class be inherited?
Answer: Because the String class is a final class, it cannot inherit the string class.
5. When a thread enters a method of an object, can other threads enter the method of the object?
Answer: No, the methods of an object can only be accessed by one thread.
6. Use the most effective method to calculate what is equal to 8?
Answer: 2<<3.
7. Can C# directly operate on memory?
Answer: This question is difficult to answer, and it is also a big question. But you can ask questions like this. C# can directly operate memory. Although pointers are rarely used, C# can use pointers. When using them, you need to add unsafe in front. In .net, the garbage collection mechanism (GC) function is used. It replaces the programmer, but in C# you cannot use the finalize method directly, but call the finalize() method of the base class in the destructor.
7. Does the array have a Length() method? Does string have this method?
Answer: There is no such method in the array, but there is this attribute, and there is this method in the string.
8. What is the difference between Error and Exception?
Answer: error means that recovery is not impossible, but very difficult. Exception means a practical or implementation problem, which means that the program cannot run normally.
9. Talk about the difference between final, finally and finalize?
Answer: Final is used to declare attributes, methods and classes, indicating that attributes are immutable, methods cannot be overridden, and classes cannot be inherited.
Finally is the part of the exception handling statement structure that is always executed.
Finallize represents a method of the object class. When executed in the garbage collection mechanism, the method of the recycled object will be called.
10, What is the difference between HashMap and Hashtable?
Answer: HashMap is a lightweight implementation of Hashtable. Non-thread-safe implementations all implement the map interface. The main difference is that the HashMap key value can be empty and null, and the efficiency can be higher than that of Hashtable.
11. What is the difference between Collection and Collections?
Answer: Collection is the superior interface of the **** class. Collections is a helper class for the **** class. It provides a series of static methods to realize the search, sorting and thread safety of various **** classes. operate.
12. What is delegation in C#? Is an event a commission?
Answer: A delegate is a safe method similar to a function pointer, but it is much safer than a pointer. It can pass a method as a parameter to another method, which can be understood as a reference to a function. Event is a message mechanism, it is a kind of delegation, and the delegation does not have a method body.
13. What is the difference between Override and Overload?
Answer: Override means overriding. It means overriding the method of the base class, and the method name, return type, parameter type, and number of parameters must be the same as the base class.
Overload means overloading. It also means overriding the method of the base class, but as long as the method name is the same, everything else can be different.
14. When you need to transfer variable values ​​​​in a BS structure, you cannot use session, coole, and application. What methods do you have?
Answer: this.server.Transfer,Querystring.
15. Can the C# indexer implementation process only be indexed based on numbers?
Answer: No, it can be of any type.
15. Can the C# indexer implementation process only be based on numerical indexing?
Answer: No, it can be of any type.
16. How to use New?
Answer: There are 3 types. The first one is instantiation such as: New Class()
The second is that public new hides the base class method. The third is that any type parameter in the generic class declaration must have a public no-argument constructor.
17. How to copy an Array into Arraylist?
Answer: Foreach (object o in Array), ArrayList.Add (0)
There are many Chinese methods. Think to yourself.
18, Overview of reflection and serialization?
Answer: Reflection: It is still difficult to give a definition of emission. Let me first talk about my understanding. Reflection provides encapsulation assemblies, modules and type objects. You can use reflection to dynamically create instances of types, bind types to existing objects, or get types from existing object types, and then call methods of the type or access fields and Attributes.
Serialization: The process of converting an object into a format for transmission via another medium. For example, serialize an object, use Http to transfer the object between the client and the server over the Internet, and use deserialization to retrieve the object from the stream at the other end.
19, Const and ReadOnly?
Answer: Const is used to declare constants during programming, and ReadOnly is used to declare runtime constants.
20. What are the similarities and differences between UDP and TCP connections?
Answer: TCP is a transmission control protocol. It provides connection-oriented, reliable, byte stream services. When users and servers interact with each other, they must establish a TCP connection before data can be transmitted. . TCP provides timeout redial and data verification functions. UDP is the User Datagram Protocol. It is a simple datagram-oriented transmission protocol and an unreliable connection.
21. How to understand processes and threads respectively?
Answer: Processes are program running units that are larger than threads. They are system running units experienced by the operating system. There must be at least one process in a program, and there must be at least one thread in a process. The division scale of threads must be It is smaller than a process. The process has an independent memory unit, and the thread is a shared memory, which greatly improves the running efficiency of the program. Multiple threads in the same process can be executed concurrently.
22, ASP. NET pages?
Answer: QueryString, session, cookies, application, server.Transfer, respose.redictor.
41. What is application domain? What is managed code? What is a strongly typed system? What is boxing and unboxing? What is overloading? What are the explanations for CTS, CLS and CLR?
Answer: Application domain: It is the isolation boundary provided for security, reliability, isolation, version control, and uninstallation. Typically created by the runtime host, the application domain provides a more secure and versatile processing unit.
Managed code: Code developed and written using the CLR compiled language editor is called managed code.
Boxing and unboxing: It is the process of converting a value type to a reference type, which is implicit. The opposite process is unboxing, which is explicit.
CTS is the common type system, CLS is the common language specification, and CLR is the common language runtime.
Strong type system: Every variable and object must have a declared type.
41. What is the difference between value types and reference types?
Answer: The value type is stored on the stack. Changing its value does not change the original value of the variable, while the reference type value is stored on the stack, and the address it refers to is stored on the stack. Changing the value does not change the original value of the variable. Its value also changes the original value of the variable. Value types are not allowed to contain null values, however nullable types can assign null to the value type l.
42. What are the authentication methods in ASP.net?
Answer: windows, forms, passport
43. Explain the meaning and functions of UDDI and WSDL?
Answer: UDDI is a unified description integration protocol. It is a set of Web-based, distributed implementation standards for information registration provided by WEB services. It also registers Web services provided for the enterprise itself so that other enterprises can Discover and access protocol standards. Provides a standards-based specification for describing and discovering services, as well as a set of Internet-based implementations.
WSDL is an XML-based interface for describing WEB services.
44. What is SOAP?
Answer: It is Simple Access Protocol. It is a protocol for exchanging information and implementing remote calls in a distributed environment. It is an XML-based protocol. Using SOAP, regardless of any transport protocol, but usually the HTTP protocol, allows any type of object or code to communicate with each other on any platform and in any language. It is a lightweight protocol.
45. How to deploy an ASP.net page?
Answer: There is a publishing mechanism in vs2003 and vs2005. vs2003 can be published and then copied and deployed.
Vs2005 can be deployed directly to the corresponding location.
46. How to understand the garbage collection mechanism in .net?
Answer: The garbage collection mechanism in .NET refers to the recycling and release of memory by the reference program. Every time an object is created using the new keyword, the runtime library must allocate memory for it from the managed heap, because the space is limited, and the garbage collection mechanism must eventually reclaim unused memory. Memory released, reused.
47. What are the three basic principles of object-oriented?
Answer: Encapsulation, inheritance, polymorphism.
48. What is the base class for all classes in .NET?
Answer: object.
50. Objects that can be traversed and accessed using foreach need to be implemented?
Answer: You need to implement the IEnumerable interface and GetEnumerator () method.
51. What is the difference between Heap and stack?
Answer: Heap is a heap. Space is allocated and released by manual operations. Its storage area is a large free storage area.
Stack is a stack, which is automatically allocated and released by the operating system. The space on the stack is limited. During the compilation of the program, memory allocation for variables and functions is performed on the stack, and the passing of parameters during function calls at runtime is also performed on the stack.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template