C #. Net classic Interview Questions and answers

Source: Internet
Author: User
Tags try catch

 

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. Can constructor be inherited? Can be overwritten?

A: constructor cannot be inherited, so it cannot be overwritten, but can be overloaded ).

5. Can I inherit the string class?

A: Because the string class is a final class, the string class cannot be inherited.

5. Can other threads enter the method of an object after a thread enters the method of an object?

A: No. The method of an object can only be accessed by one thread.

6. Use the most effective method to calculate the number of equal 8 pairs?

Answer: 2 <3.

7. 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 programmers. However, the Finalize method cannot be directly used in C, instead, the finalize () method of the base class is called in the destructor.

7. Does the array have length () and method? Does string have this method?

A: This method is not available in the array, but it has this attribute. This method is available in string.

8. 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.

9. 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.

10. 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.

11. What is the difference between collection and collections?

A: collection is the upper-level interface of the Collection class. collections is a help class for the Collection class. It provides a series of static methods for searching, sorting, and thread-safe operations on various sets.

12. 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.

13. What is the difference between override and overload?

A: override indicates the method used to override the base class. In addition, the method name, return type, parameter type, and number of parameters must be the same as that of the base class.

Overload indicates that the method of the base class is overwritten, but the method name can be different if it is the same.

14. When you need to pass variable values in a bsstructure, you cannot use sessions, coolke, and application. How many methods do you have?

A: This. server. Transfer, querystring.

15. Can I use the C # indexer to implement a digital index?

A: No. It can be of any type.

15. Can I use the C # indexer to implement a digital index?

A: No. It can be of any type.

16. Is there a new usage?

A: There are three types. The first type is instantiation, for example, new class ()

The second method is to hide the base class using public new.

Third, any type parameter in the generic class declaration must have a common no-argument constructor.

17. Any one that copies an array to the arraylist?

A: foreach (Object o in array), arraylist. Add (0)

There are many methods. Think for yourself.

18. Overview of reflection and serialization?

A: Reflection: it is still difficult to define the next launch. Let's talk about my understanding here. Reflection provides encapsulated assembly, module, and type object. You can use reflection to dynamically create a type instance, bind the type to an existing object, or obtain the type from the existing object type, then, call methods of the type, access fields, and properties.

Serialization: the process of converting an object to a format transmitted by another media. For example, to serialize an object, Use http to pass the object between the client and server over the Internet, and use deserialization on the other end to obtain the object from the stream.

19, const and readonly?

A: const is used to declare constants during programming, and readonly is used to declare the runtime constant.

20. What are the similarities and differences between UDP and TCP connections?

A: TCP is a transmission control protocol that provides connection-oriented and reliable byte stream services. When users and servers exchange data with each other, data can be transmitted only after a TCP connection is established before data interaction. TCP provides the time-out redial function to verify data. UDP is a User Datagram Protocol, a simple datagram-oriented transmission protocol, and an unreliable connection.

21. How do processes and threads understand each other?

A: A process is a program running unit larger than a thread. It is a system running unit experienced by the operating system. A program must have at least one process and one process, there must be at least one thread. The thread division scale is smaller than the process, and the process has independent memory units. The thread is shared memory, this greatly improves the program running efficiency. multiple threads in the same process can be executed concurrently.

22. asp. How many methods can be used to pass values between pages?

A: querystring, session, cookies, application, server. Transfer, respose. redictor.

41. 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.

41. What is the difference between the value type and the reference type?

A: The value of the value type is stored in the stack. Changing the value does not change the original value of the variable. The value of the reference type is stored in the stack, the referenced address is stored in the stack. changing its value changes the original value of the variable. The value type cannot contain null values. However, the null type can be assigned to the value type L.

42.asp.net what are the authentication methods?

A: Windows, forms, and passport

43. What are the meanings and functions of UDDI and WSDL?

A: UDDI is a unified description Integration Protocol. It is a set of web-based, distributed, and standardized information registration implementation standards for Web Services, it is also a protocol standard that allows other enterprises to discover and access web services provided for the enterprise itself. Standard-based specifications are provided for describing and discovering services, and a set of Internet-based implementations are also provided.

WSDL is an XML-based Web service interface.

44. What is soap?

A: simple access protocol. Is a protocol for exchanging information and implementing remote calls in a distributed environment. Is an XML-based protocol. With soap, you can ignore any transmission protocol, but it is usually HTTP protocol that allows any type of objects or code to communicate with each other in any language on any platform. It is a lightweight protocol.

45. How to deploy an Asp.net page?

A: There is a publishing mechanism in vs2003 and vs2005. vs2003 can be released and deployed in replication.

Vs2005 can be directly deployed to the corresponding location.

46. How to understand the garbage collection mechanism in. Net?

A: The garbage collection mechanism in. Net refers to the collection and release of memory by reference programs. When an object is created with the New Keyword each time, the runtime database allocates memory for it from the managed heap, because the space is limited, and the final garbage collection mechanism needs to recycle the unused memory. The memory has been released and used again.

47. What are the three basic object-oriented principles?

A: encapsulation, inheritance, and polymorphism.

48. What is the base class of all classes in. Net?

A: object.

50. Can I use foreach to traverse the accessed object?

A: You need to implement the ienumerable interface and the getenumerator () method.

51. What is the difference between heap and stack?

A: heap is a heap, and space is allocated and released by manual operations. It has a large free storage zone.

The stack is automatically allocated and released by the operating system, and the space on the stack is limited. During compilation, both the variable and function allocation memory are on the stack, and the parameter transfer during function calling is also on the stack.

Bytes ----------------------------------------------------------------------------------------------------------------

C # What are the differences between property and attribute? What are their respective uses? What are the benefits of this mechanism?
One is an attribute field used to access a class, and the other is a feature used to identify additional properties such as classes and Methods. C # Can I perform direct operations on the memory?
It can maintain database integrity and consistency. Do you like to use triggers or write business logic? Why?
Trigger, good performance, transactional
ADO. What are the main improvements to net over ado?
Added dataset and so on. You do not need to keep the connection at any time to improve performance.
ASP. Net compared with ASP, what are the main advances?
ASP interpreter and aspx compiler help to protect source code
What is the delegate in C? Is an event a delegate?
Delegation is a safe function pointer, and events are a message mechanism.
Do you know about XMLHTTP and WebService? Briefly describe its features and functions
XMLHTTP can actively obtain remote web code, similar to httpwebrequest
What is the difference between an interface and an abstract class? What is the basis for using interfaces and abstract classes?
Interfaces are used for standardization, and abstract classes are used for commonality.
Differences between stored procedures and functions
Stored procedures are compiled and stored in databases.
What is a transaction?
Atomicity
What is the role of a cursor? How do I know that the cursor has reached the end?
Indicates the location of the current record and checks for null
Triggers are divided into trigger beforehand and trigger afterwards. There are differences between these two triggers. What is the difference between statement-level triggering and row-level triggering.
One is before the operation, the other is after the operation
Describes several common methods for passing parameters between pages in. NET and their advantages and disadvantages.
Session (viewstate) is simple but easy to lose
Application global
Cookies are simple but may not be supported and may be forged.
Input type = "hidden" is simple and may be forged
The URL parameter is simple and displayed in the address bar with a limited length.
The database is stable and secure, but its performance is relatively weak.
Describe the error handling mechanism in. NET and give an example.
Try catch final
Please describe the meaning of a strong name
Has its own key, which can be public in GAC
List several cycles in C # and point out their differences
For wile foreach
Indicate all types of base classes in. net
Object
Indicate the meaning of GAC
Global Assembly Cache
What is the difference between the value type and the reference type?
Differences between values and pointers
How do I understand static variables?
One variable is shared by all instances.
How many requests can be sent to the server?
Get post
If you need to pass variable values in a B/S structure, but you cannot use session, cookie, and application, how can you handle them?
Input type = ""
URL
Database
If. NET is used as a B/S structure system, how many layers of structure do you use to develop the relationship between each layer and why do you need to layer it like this?
Layer 3, performance, logic, Data, security, maintainability
How many stages are involved in the software development process? What is the role of each stage?
Requirement Analysis, architecture design, code writing, QA, deployment
How do I pass Chinese parameters through hyperlinks?
Urlencode urldecode
Traverse all textbox controls on the page and assign them string. Empty
Foreach
Which of the following methods can be used to access the member functions and attributes of another class? For more information, see.
Direct or reflection of the same name Control
If you need to record the number of instances of the class, please write a simple class to prove.
Const static int classnum = 0;
Classnum ++;
Class A is the base class of class B and has its own constructor. For example, we recommend that you describe the execution process of Class B's constructor from Instantiation to extinction.
Construct the parent child and analyze the opposite
To process a string, remove the spaces at the beginning and end of the string. If there are consecutive spaces in the string, only one space is reserved, that is, multiple spaces are allowed in the string, however, the number of consecutive spaces cannot exceed one.
String inputstr = "xx ";
Inputstr = RegEx. Replace (inputstr. Trim (),"*","");
In C #, what are the meanings of using and new keywords?
Using command and statement new create instance new hide methods in base class
Using introduces namespaces or uses unmanaged Resources
New create an instance or hide the parent class Method
What are the differences between classes and structures?
The class is a reference type and the structure is a value type.
What is SQL injection and how to prevent it? For example.
Attackers can exploit SQL keywords to attack websites. Filter keywords, etc.
What is the output of the following code? Why?
Int I = 5;
Int J = 5;
If (object. referenceequals (I, j ))
Console. writeline ("Equal ");
Else
Console. writeline ("not equal ");
Write a method to flip a string and add some conditions, such as "," and "." To design test cases for it.
Inputstr = inputstr. tochararray (). Reverse (). tostring ();
What is reflection?
Dynamically Retrieve assembly information
How to Write Design Patterns with Singleton
New in the static attribute, constructor private
C # What is the garbage collection mechanism?
Check the reference when the memory of each of the three generations is full.
What is application pool?
Web applications, similar to thread pool, improve concurrency Performance
What are the advantages and disadvantages of linked lists and arrays.
One can be dynamically increased, one can be fixed (redim in VB), and the performance array is good.
What is a friend function?
Friendly declaration, which allows you to access protect-level methods
What is a virtual function?
Can be rewritten
What is an abstract function?
Must be overwritten
What is memory leakage? How can I determine whether a memory leak is detected in the simplest way?
C ++ and C forget to release the memory, and the memory will not be allocated again
What are the two indexes of 1 SQL server? What is the role of an index? What are the advantages and disadvantages of indexes?
Cluster and non-cluster, accelerating search, taking up additional controls, and maintaining indexes takes time
What is XML?
Extensible Markup Language, which can be used as configuration files, data transmission, and data storage
Briefly describe the access permissions of private, protected, public, and internal modifiers.
PRIVATE: a private member that can be accessed within the class.
Protected: protects members, which can be accessed within the class and in the inheritance class.
Public: A Public member. It is completely public and has no access restrictions.
Internal: accessible within the same namespace.
Differences between processes and threads
A process is the unit of resource allocation and scheduling by the system. A thread is the unit of CPU scheduling and scheduling. A process can have multiple threads which share the resources of the process.
The role of adding static before member variables and member functions
They are called common member variables and common member functions, and also known as class member variables and class member functions. They are used to reflect the status of the class respectively. For example, a class member variable can be used to count the number of class instances. class member functions are responsible for such statistical actions.
Differences between malloc and new
New is the key word of C ++. Malloc must be allocated in bytes when allocating memory. New can be automatically allocated according to the object size and can call constructors. It can be said that new is the object, but malloc is not. In essence, when new allocates memory, additional information is added before and after the actual memory block. Therefore, new uses more memory than malloc.
Stack and stack differences
STACK: the stack is automatically allocated and released by the compiler. Variables defined in the function body are usually on the stack.
Heap: usually assigned and released by programmers. The memory allocated by using new and malloc functions is on the heap.
Stack is the data structure provided by the machine system, while stack is provided by the C/C ++ function library.
Stack is a function provided by the system. It features fast and efficient. Its disadvantage is that it has restrictions and data is not flexible. Stack is a function provided by function libraries. It features flexibility and convenience and wide range of data adaptation, however, the efficiency is reduced. The stack is the system data structure, which is unique for processes/Threads. The heap is the internal data structure of the function library, which is not necessarily unique. Memory allocated by different heaps cannot be operated on each other. Stack space is divided into static allocation and dynamic allocation. Static allocation is completed by the compiler, such as automatic variable allocation. Dynamic Allocation is completed by the alloca function. The stack does not need to be released dynamically (automatically), so there is no release function. For the sake of portable programs, dynamic stack allocation is not encouraged! Heap space allocation is always dynamic. Although all data spaces are released back to the system at the end of the program, precise memory application/release matching is the basic element of a good program.
In. net, can system. Web. UI. Page be inherited?
Yes
What is the biggest difference between ASP. NET 2.0 (vs2005) and your previous development tool (. NET 1.0 or other? Which development ideas (pattern/architecture) were available on your previous platform?
1 ASP. NET 2.0 encapsulates and packages some code, so it reduces a lot of code compared to the same function of 1.0.
2. Both the code separation and page embedding server-side code modes are supported. In the previous version 1.0 ,.. Net prompt help is only available in separated code files. You cannot embed server-side code on the page to get help tips,
3. When switching code and design interfaces, 2.0 supports cursor positioning.
4. When binding data, you can perform operations such as paging, update, and delete on tables in a visualized manner, facilitating beginners.
5. More than 40 new controls are added to ASP. NET, reducing the workload.
What is the error handling mechanism of. Net?
The. NET error handling mechanism adopts the try-> catch-> finally structure. When an error occurs, it is thrown layer by layer until a matching catch is found.
Differences between heavy load and coverage
1. the override of a method is the relationship between the subclass and the parent class, and the vertical relationship. the overload of a method is the relationship between methods in the same class and the horizontal relationship.
2. Override can only be composed of one method, or can only be composed of one method. Method Overloading is the relationship between multiple methods.
3. The overwrite request parameter list is the same; the reload request parameter list is different.
4. In the override relationship, the method body called is determined based on the object type (the object corresponds to the bucket type, the method body is selected based on the real parameter table and the form parameter table during the call.
This article briefly introduces your understanding of the remoting and WebService technologies under the Microsoft. NET Framework and their practical applications.
WS primarily uses http to penetrate the firewall. Remoting can improve the efficiency by using TCP/IP and binary transmission.
What is the delegate in C? Is an event a delegate?
Delegation is a safe function pointer, and events are a message mechanism.
There are several usage methods for new
First: New Class ();
Method 2: Overwrite
Public new xxxx (){}
Third: the new constraint specifies that any type parameter in the generic class declaration must have a common non-parameter constructor.
How to copy an array to arraylist
Foreach (Object o in array) arraylist. Add (O );
Data sources that can be connected by DataGrid. datasouse
Dataset, datatable, dataview, ilist
Overview reflection and serialization
Reflection: The Assembly contains modules, while the module contains types and types, including Members. Reflection provides encapsulated assembly, module, and type objects. You 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 a method of the type or access its fields and attributes.
Serialization: serialization is the 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, deserialization reconstructs the object from the stream.
Overview o/R Mapping principles>
Use reflection to configure database table ing
What are the characteristics of classes modified with sealed?
The sealed modifier is used to prevent other classes from being derived from the modified class. If a sealed class is specified as the base class of another class, a compile-time error occurs.
The sealed class cannot be an abstract class at the same time.
The sealed modifier is mainly used to prevent unintentional derivation, but it can also promote some runtime optimization. Specifically, because the sealed class will never have any derived class, the call to the virtual function Member of the sealed class instance can be converted to a non-virtual call for processing.

What is an application domain? What is regulated code? What is a strong system? What is packing and unpacking? What is overload? What are the explanations of CTS, CLS, and CLR?
A: boxing refers to converting the value type to the reference type. From the perspective of Ms Il, it looks like boxing. If you remember correctly, the value is transferred from the stack to the heap. on the contrary, a method with the same name and number of parameters can return the same method. when the CLR is running in a common language, the rest is unclear.
How to Understand delegation?
A: It is said to be equivalent to a function pointer. If a delegate is defined, the method can be called without calling the original method name.
Delegation has the following features:
The delegate is similar to a C ++ function pointer, but it is type-safe.
The delegate allows passing methods as parameters.
A delegate can be used to define a callback method.
The delegate can be linked together. For example, multiple methods can be called for an event.
The method does not need to be exactly matched with the delegate signature. For more information, see covariant and inverter.
C #2.0 introduces the concept of anonymous methods, which allow passing code blocks as parameters instead of Individually Defined methods.
The similarities and differences between UDP and TCP connections.
The former is only transmitted, no matter the data is not available, no connection is required. The latter ensures that the transmitted data is accurate and must be linked.
How do processes and threads understand each other?
The process is Lao Tzu, The thread is the son, and there is no son without Lao Tzu. A Lao Tzu can have multiple sons. A son can be another son, and a Lao Tzu can have another son.
What is soap and what applications are there.
A: Simple Object Access Protocol (SOAP) is a protocol used to exchange information and execute remote process calls in a distributed or distributed environment. It is an XML-based protocol. When using soap, you do not need to consider any specific transmission protocol (the most commonly used HTTP protocol). You can allow any type of objects or code to communicate with each other in any language on any platform. This type of communication uses messages in XML format.
1. Fill in the blanks: (1) object-oriented languages have ___ inheritance, encapsulation, and polymorphism.
(2) You need to implement the ienumerable interface or declare the type of the getenumerator Method for objects that can be accessed through foreach.
(3) list the five main objects in ado.net
Command, connection, dataset, dataadapter, datareader

 

 

 

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.