C # And. Net interview questions, including answers

Source: Internet
Author: User

1. What is the difference between classes and structures in. Net?
A: The structure and class have a general syntax, but the structure is limited by more than the class. The structure cannot declare that there is a default constructor. The replicas of the structure are created and destroyed by the compiler. Therefore, the default constructor and destructor are not required. The structure is a value type, so changes made to the structure variables will not affect their original values, while the class is an application type. Changing the value of the variable will change its original value. The declarative structure uses the struck keyword, the declarative class uses the class keyword, and the structure passed to the method is passed through the value instead of the reference. Unlike classes, the New Keyword can be used for Schema Instantiation. Class.
2. What are the conditions for deadlock? How to overcome it?
A: The system has insufficient resources, the process promotion sequence is inappropriate, and the resource allocation is improper. Each resource can only be used by one process, and one resource requests resources, at this time, the resource is blocked, and the acquired resource is not put. When the process obtains the resource, it cannot be forcibly deprived before it is used up.
3. Can an interface inherit the interface? Can an abstract class implement interfaces? Can an abstract class inherit an object class?
A: An interface can inherit interfaces. An abstract class can implement interfaces. An abstract class can inherit object classes. However, a condition is that the object class must have a clear constructor.
4. C # Can I directly perform operations on the memory?
A: This question is difficult to answer. It is also a big question. However, you can answer questions in this way. C # can directly operate on the memory. Although pointers are rarely used, C # can use pointers. When using pointers, you must add unsafe at the front.. net uses the garbage collection mechanism (GC) function, which replaces Program But the Finalize method cannot be directly used in C #. Instead, the finalize () method of the base class is called in the destructor.
5. What is the difference between error and exception?
A: Error indicates that the restoration is not impossible, but it is very difficult. Exception indicates an actual or implementation problem. It indicates that the program runs normally and cannot occur.
6. What are the differences between final, finally, and finallize?
A: Final is used to declare attributes. Methods and classes indicate that attributes are unchangeable, methods cannot be overwritten, and classes cannot be inherited.
Finally is the part in the structure of the exception handling statement that is always executed.
Finallize indicates an object class method. When executed in the garbage collection mechanism, the method of the object to be recycled is called.
7. What is the difference between hashmap and hashtable?
A: hashmap is a lightweight Implementation of hashtable. All non-thread-safe implementations implement the map interface. The main difference is that the hashmap key value can be null and the efficiency can be higher than that of hashtable.
8. What is delegation in C? Is an event a delegate?
A: delegate is a safe way similar to function pointer, but it is much safer than pointer. It can pass a method as a parameter to another method, it can be understood as a reference to a function. An event is a message mechanism, which is a delegate without a method body.
9. How do I pass values between ASP. NET pages?
A: querystring, session, cookies, application, server. Transfer, respose. redictor.
10. What is an application domain? What is managed Code ? What is a strong system? What is packing and unpacking? What is overload? What are the explanations of CTS, CLS, and CLR?
A: application domain: it is the isolation boundary for security, reliability, isolation, and version control, and uninstallation. It is generally created by the runtime host, and the application domain provides a safer and more useful processing unit.
Managed code: the code written by the CLR compilation language editor is called managed code.
Packing and unpacking: the process of converting the value type to the reference type is implicit. The opposite process is unpacking and explicit.
CTS is a public-type system, CLS is a public-language standard, and CLR public-Language Runtime Library.
Strongly typed system: each variable and object must have a declarative type.
11. What are the three basic object-oriented principles?
A: encapsulation, inheritance, and polymorphism.
12. What is the base class of all classes in. Net?
A: object.

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.