33 C # ,. Net classic interview questions and answers

This article focuses on the number of common C # , .Net classic interview questions such as "the difference between class and structure .NET", "ways to pass values between ASP.NET page?", And gives the answer brief , hoping to learn C # , .Net readers help.

   1, you talk about the difference in class and structure of .NET?

   A: The structure and grammar classes with the general, but by confining structure to be more than a class. Structure can not affirm the default constructor, a copy of the structure and the compiler is created and destroyed, so no default constructor and destructor. Structure is a value type, so the changes do not affect the structural variables of its original value, and the class is the application type, change the value of its variables will change its original value. Struck keyword stated structures, the class declaration using the class keyword, the method is a transfer structure is passed by value, rather than by reference. Unlike classes, examples of structure may not use the New keyword. Class can implement the interface.

   2, a necessary condition for deadlock? How to overcome?

   A: The system's lack of resources, inappropriate order to promote the process, misallocation of resources, a resource can only be used by a process, a request for resources, at a time when the resources have been blocked resources, have access to resources and hold ago, when the process of access to resources, not used, it can not be forcibly deprived.

   3, the interface can inherit an interface? Abstract class is the interface can be achieved? Abstract class can inherit entity class?

   A: Interface interface can be inherited, abstract classes can implement an interface, abstract class can inherit entity class, but on one condition, that condition, the entity class must have explicit constructor.

   4, whether Constructor constructor can be inherited? Can be Override?

   A: Constructor can not be inherited, and therefore can not be rewritten (Overriding), but can be overloaded (Overloading).

   5, when a thread enters a method object, the other threads can enter the object's methods?

   A: No, an object's methods can only be accessed by a thread.

   6, the most effective way to figure 8, have been for a few?

   A: << 2 3.

   7, C # if memory can operate directly?

   A: This question is more difficult to answer, is also a big problem. But can this quiz. C # can operate directly on memory, although rarely used pointers, but you can use C # is a pointer, it is necessary to use in .net ,, plus in front of unsafe when used in garbage collection (GC) function, it replaces the programmer, but in C # finalize method can not be directly used, but class group call finalize () method in the destructor.

   8, Error and Exception There is a difference?

   Answer: error indicates that the recovery is not impossible, but very difficult, exception or represents a practical implementation issues, which represents the normal operating procedures can not happen.

   9, talk about the difference between the final, finally, finallize of?

   A: final declaration for the properties, methods, and classes, attributes represent immutable, the method may not be covered, the class can not be inherited.

Finally exception handler is in sentence structure, represents part is always executed.

   Finallize representation is a method object class, when executed in the garbage collection method will be called recycled object.

   10, HashMap and Hashtable difference?

   A: HashMap Hashtable is a lightweight implementation, non-thread- safe implementations they have achieved a map interfaces, the main difference is HashMap key can be null null, efficiency can be higher than Hashtable.

   11, Collection and Collections of the difference?

   A: Collection is a collection of higher-level interface to the class, Collections is help for a class set of classes, which provides a series of static methods to achieve a variety of search collection, sorting, thread- safe operations.

   12, C # What is the commission? Event is not a delegate?

   A: The commission is a safe similar to function pointers, but she wanted more security than a pointer, it can be used as a method parameter passed to another method, it can be understood as a reference point function. Events is a messaging mechanism, it is a delegate, delegate without a method body.

   13, Override, Overload, the difference?

   A: Override means are rewritten, which represents the base class rewriting, and method name, return type, parameter types, the number of parameters to the same base class.

   Overload is overloading is meant, it also represents a weight


Base class to write, but as long as the method names are the same, the other can be different.

   14, a BS in structures need to pass variable values ​​can not be used session, coolke, application, you have several methods?

   答:this.server.Transfer,Querystring.

   15, C # indexer kinds of implementation, if only based on a numeric index?

   A: No, can be of any type.

   16, New kind of usage?

   A: There are three kinds, the first is instantiated as: New Class ()

  The second is the base class public new Hide

  The third is that any type of parameters in the generic class declaration must have a public no argument constructor.

   17, any attempt to copy an Array to Arraylist in?

   答:Foreach (object o in Array), ArrayList.Add (0)

  Etc. There are a lot of ways. They want.
  
  18, overview reflection and serialization?
  A: reflex: to give a definition of emission is quite difficult, here to talk about my understanding. Providing reflective package assemblies, modules and types of objects, instances can be created dynamically with a reflection type, the type of binding to an existing object, or get the type of the existing object type, and then call a method or type of access fields and Attributes.

  Serialization: convert an object to another medium format during transmission. For example, a sequence of objects, with Http client via the internet and server passing between the object, with the object deserialized back from the stream obtained at the other end.

19, Const and ReadOnly?

   A: Const to declare a constant affirming programming, ReadOnly to declare runtime constants.

   20, UDP and TCP connections and have similarities and differences?

   A: TCP transmission control protocol , providing a connection-oriented, reliable, byte stream service, when the user and the server time data exchange with each other, must be carried out in order to transmit data after the TCP connection in front of their data exchange. TCP provides a timeout redial, test data capabilities. UDP User Datagram Protocol is a simple datagram-oriented transmission protocol , the connection is not reliable.

   21, processes and threads, respectively, how to understand?

   A: The process is larger than the thread running unit by the operating system are keenly aware of system operation unit, a program must have at least a process, there is a process, scale division must have at least one thread, the thread than process smaller, the process has a separate memory unit, a thread is a shared memory, which greatly improves the efficiency of the program multiple threads of the same process can be executed concurrently.

22, passed several ways values ​​between ASP.NET pages?

答:QueryString,session,cookies,application,server.Transfer,respose.redictor.

   23. What is the application domain? What is a managed code? What is a strongly typed system? What is boxing and unboxing? What is overloaded? CTS, CLS and CLR, respectively, what explanation?

   A: The isolation boundary is to the safety, reliability, isolation, and version control, and the uninstall program provided: application domain. It is usually created by the runtime hosts, application domains provide a safer, more versatile processing units.

  Managed code: Use CLR compiler language editor called to develop code written in managed code.

  Boxing and unboxing: the value is cast to the type of process reference is implicit, unpacking process is the reverse, is explicit.

   CTS is a common type system, CLS is Common Language Specification, CLR common language runtime.

  Strongly typed system: every variable and object must have a declared type.

   24. The difference between value types and reference types?

   A: The type value is stored in the stack, change its value, does not change the original value of the variable, and the type of reference value is stored in the stack, the address of its reference is stored in the stack, changing its value also changed the original value of the variable. Value types do not contain null values, however, may be empty types can be assigned to a null value type l.

   25. ASP.net authentication options?

   答:windows,forms,passport

   26. Explain the significance and role of UDDI, WSDL is?

   A: UDDI is Universal Description integration protocol is a set of Web-based, distributed, and registration information for the WEB service implementation provided standards, while registered as a Web service is also offered for the company itself to allow other companies to discover and protocol standard access. Specification provides a standards-based, and is used to describe the discovery service, also provides a set of Internet-based implementation.

   This WSDL is an XML-based description of WEB service interface.

27. What is SOAP?

   A: Yes, simply access protocol. In a distributed environment, exchange information and implement the protocol remote calls. It is an XML-based protocol. Using SOAP, any transport protocol may not be considered, but it is usually HTTP protocol allows any type of object or code, on any platform, communicate with each other in any language. It is a lightweight protocol.

   28. How to deploy an ASP.net page?

   A: vs2003, vs2005 have published inside mechanism, vs2003 can publish and then copy the deployment.

   Vs2005 can be deployed directly to the corresponding position.

   29. How to understand garbage collection in .net?

   A: The garbage collection in .NET is referenced memory recovery and release. Each time an object is created with the new keyword, run-time library must be assigned from the managed heap memory, because space is limited, the ultimate garbage collection mechanism to reclaim unused memory. Memory has been released and re-use.

   30. The three basic principles of object-oriented?

   A: encapsulation, inheritance, polymorphism.

   31. in .NET base class for all classes?

   Answer: object.

   32. foreach traversal can access objects need to achieve?

   A: The need to implement IEnumerable interface and the GetEnumerator () method.

   33. Heap and stack the difference?

   A: Heap heap space is allocated and released by the manual operation, its storage area big free storage area.

   Stack is the stack, the operating system is automatically assigned by the release and, on the stack space is limited. Program allocates memory variables and functions are carried out on the stack during compilation, and pass parameters when the function call is made on the stack at run time

Reproduced in: https: //www.cnblogs.com/zhangchenliang/archive/2010/04/04/1703994.html

Guess you like

Origin blog.csdn.net/weixin_33943347/article/details/93496019