Cainiao fly slowly...

Source: Internet
Author: User
Tags finally block

Some Basic Concepts

Problem description: Reference Type & Value Type

1. Is string a value type or a reference type?

Reference type. The proof is as follows:

Let's take a look at the following:Code

Using System;
Using System. Collections. Generic;

Public   Class Myclass
{
Public   Static   Void Main ()
{
String S = " ABC " ;
String A = S;
S = " Def " ;
Console. writeline ( " {0}, {1} " , A, S );
}

}

The output is ABC, def
We all know that arrays are of reference type. Please refer to the Code Section:

Using System;
Class Myclass
{
Static   Void Main ()
{
Int [] Arr1 = { 1 , 2 , 3 , 4 , 5 };
Int [] Arr2 = Arr1;
Arr1 [ 1 ] = 200 ;
Foreach ( Int I In Arr2)
Console. writeline (I );
}
}

We all know that when values are attached to a value type, we attach a copy of our own to another variable, which will not affect each other afterwards. The reference type copies the address in the stack to another variable, which points to the same one. Therefore, operations on a variable will affect another variable, in the preceding example, arr2 [1] = 200 instead of 2. So we can now consider string as a value type.
The following code once again shows that it has the value type feature.

Using System;
Class Myclass
{
Static   Void M ( String S)
{
S = " ABCD " ;
}
Static   Void Main ()
{
String S = " Efgh " ;
M (s );
Console. writeline (s );
}
}

Output efgh
However, in fact, string is of the reference type. to reference msdn, "A String object is called an immutable (read-only), because once this object is created, the value of this object cannot be modified. It seems that the method for modifying the string object is actually to return a New String object containing the modified content ."
After reading this sentence, do you feel suddenly enlightened? Let me make it more popular."Re-assign a value, that is, re-allocate a new memory in the heap to give it a new value, that isA new object is created.Instead of overwriting the original value. The original value will be recycled by CG."
If you want to define strings that change frequently and use the string class, isn't CG very memory-consuming if it cannot be recycled in time?
So another class is recommended for MS: Class.

The existence of system. Text. stringbuilder is to prove that string is of the reference type.
Constraints in generics where T: the struct type must be a value type (struct) input string cannot prove that it is a reference type
So my personal understanding of string is that it is a reference type, but it has the value type feature!

2. What is the difference between class and struct?

Class is a reference type and is allocated to the memory stack. It can be instantiated and inherited;

Struct is a value type and is allocated to the memory stack.

3. What is the difference between class and object?

Class is an automobile template or is used to build an automobile plan. The automobile itself is an example of these plans, so it can be seen as an object.

4. What are the differences between public, protect, private, and internal?

Public: public to all classes and members, unrestricted access;
Protected:Only public the class and its derived classes;
PRIVATE: Only public for this class;
Internal:Only values that contain this classProgramCentralized access to this class (only a separate project, not the entire solution );
Protected internal:It can only be accessed in this class, a derived class, or a program containing this class.

5. What are the features of "class" in Object-Oriented Methods? (ABC)

A. attributes;

B. method;

C. events;

D. object;

Note: A class consists of "attributes, methods, and events.

6. object-oriented technology has three basic features: (ABC)

A. encapsulation;

B. Inheritance;

C. polymorphism;

D. Association;

 

7. What is packing and unpacking?

Converting from the value type interface to the reference type is called packing; converting from the reference type to the value type is easier than unpacking.

8. What is GC? Why GC?

GC is the garbage collector. Programmers don't have to worry about memory management, because GC will automatically manage. To request garbage collection, you can call one of the following methods:

System. GC ()

Runtime. getruntime (). GC ()

9,What isWhat are the applications of soap.
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 the XML format of the message, see: http://playist.blogchina.com/2521621.html

10,C #What is delegation in?Is an event a delegate??

A: A delegate can substitute a method as a parameter to another method.

A delegate can be understood as a reference to a function.

Yes, it is a special delegate

11,Differences between override and overload

A: What is the difference between override and overload. Overload means that the method name is the same. The parameters or parameter types are different and are reloaded multiple times to meet different needs.

Override is used to override functions in the base class. To meet your needs.

12,What are the explanations of CTS, CLS, and CLR?

A: CTS: a general-purpose language system. CLS: general language specification. CLR: Common Language Runtime Library.

13,Is run () or start () used to start a thread ()?

A: To start a thread is to call the START () method so that the virtual processor represented by the thread is runable, which means it can be scheduled and executed by JVM. This does not mean that the thread will run immediately. The run () method can generate the exit sign to stop a thread.

14,Does the array have the length () method? Does string have the length () method?

A: The array does not have the length () method. It has the Length attribute. String has the length () method.

15,What is the difference between sleep () and wait?

A: The sleep () method is used to stop a thread for a period of time. After the sleep interval expires, the thread may not resume execution immediately. This is because at that time, other threads may be running and not scheduled to give up execution, unless (a) the thread "wakes up" has a higher priority (B) the running thread is blocked for other reasons.

When wait () is a thread interaction, if the thread sends a wait () call to a synchronization object X, the thread will pause the execution and the called object will enter the waiting state, wait until the wake-up or wait time is reached.

16,Let's talk about the differences between final, finally, and finalize.

A: Final-modifier (keyword) If a class is declared as final, it means that it cannot generate a new subclass and cannot be inherited as a parent class. Therefore, a class cannot be declared both abstract and final. Declare variables or methods as final to ensure that they are not changed during use. Variables declared as final must be declared with an initial value, which can only be read and cannot be modified in future references. Methods declared as final can only be used and cannot be reloaded.

Finally-The Finally block is provided for troubleshooting. If an exception is thrown, the matched catch clause is executed, and the control enters the Finally block (if any ).

Finalize-method name. Java technology allows you to use the finalize () method to clear objects from the memory before the Garbage Collector clears them. This method is called by the garbage collector when it determines that this object is not referenced. It is defined in the object class, so all classes inherit it. Subclass overwrites the finalize () method to sort system resources or perform other cleanup tasks. The finalize () method is called before the Garbage Collector deletes an object.

17,What is the difference between a process and a thread?

A: 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.

18,What is the difference between stack and stack?

A: 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.

19,What is a virtual function? What is an abstract function?

A: virtual functions: functions that are not implemented can be inherited and overwritten by sub-classes. Abstract function: Specifies a function that must be implemented by a non-virtual subclass and must be overwritten.

20,What is a user control in Asp.net?

A: The user control is generally used when the content is mostly static, or a little changes... it is relatively large... similar to include... in ASP, but the function is much more powerful.

21,ASP. Net compared with ASP, what are the main advances?

A: ASP interpretation form and aspx compilation form help improve the performance and protect the source code.

22,Describes several common methods for passing parameters between pages in. NET and their advantages and disadvantages.

A: Session (viewstate) is simple but easy to lose.

Application global

Cookies are simple but may not be supported and may be forged.

Input tType = "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.

 

23,In C #, what are the meanings of using and new keywords? Using command and statement new create instance new hide methods in the base class.

A: Using introduces namespaces or uses unmanaged resources.

New create an instance or hide the parent class Method

24,When integer a is assigned to an object, integer a is?

Answer: Packing

25,Which of the following types of Class Members are accessible?

A: This.; new class (). method;

26,The keyword of the delegate statement is ______?

A: Delegate.

27,What are the characteristics of classes modified with sealed?

A: It is sealed and cannot be inherited.

28,In. Net hosting code, we don't have to worry about memory vulnerabilities. This is because ______?

A: GC.

29,What is the error handling mechanism of. Net?

A: the. NET error handling mechanism adopts the try-> catch-> finally structure. When an error occurs, it is thrown layer by layer until a matched catch is found.

30,C #MediumPropertyAndAttributeDifference,What are their respective uses?,What are the benefits of this mechanism??

A: attribute: The base class of the custom attribute. property: the attribute in the class. One is the attribute used to access the field of the class, and the other is the feature used to identify additional properties of the class and method.

31,C #Can I perform direct operations on the memory??

A: In.. net ,. net references the garbage collection (GC) function, which replaces programmers. However, in C #, the Finalize method cannot be directly implemented, but the finalize () method of the base class is called in the destructor.

32,.

& Is a bitwise operator that represents bitwise and operation, & is a logical operator that represents logic and (and ).

33,Can the overloaded method change the type of the returned value?

A: The overloaded method can change the type of the returned value.

34,What is the difference between error and exception?

A: Error indicates that the restoration is not an impossible but difficult case. For example, memory overflow. It is impossible to expect the program to handle such a situation.

Exception indicates a design or implementation problem. That is to say, it indicates that if the program runs normally, it will never happen.

35,What is the difference between overload and overwrite?

Answer: 1. The method overwrites the relationship between the Child class and the parent class. The method overload is the relationship between the 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.

What is the difference between override and overload? (Supplement)

Overriding and overloading are different manifestations of Java polymorphism.
Overriding is a manifestation of the polymorphism between the parent class and the Child class, and overloading is a manifestation of the polymorphism in a class.

If a subclass defines a method with the same name and parameter as its parent class, we say this method is overwritten ). When a subclass object uses this method, it calls the definition in the subclass. For it, the definition in the parent class is "blocked.
If multiple methods with the same name are defined in a class, they may have different numbers of parameters or different parameter types, it is called overloading ). The overloaded method can change the type of the returned value.

36,Can I describe the implementation process of the indexer in C # To see if it can only be indexed by numbers?

A: No. Any type can be used.

37,In C #, use text or images to describe the differences between string STR = NULL and string STR =.

A: NULL has no space reference;

"" Is a string with a space of 0;

38,Similarities and differences between interfaces and classes in C #

Interfaces and classes are classes. Different things, interfaces only contain methods or attribute declarations, and do not contain code for specific implementation methods. interfaces can implement multiple inheritance While classes can only be single inheritance, the class that inherits the interface must implement the methods or attributes declared in the interface. The interface mainly defines a standard and Unified Call method, which plays an increasingly important role in large projects.

39,In. Net (C # Or VB.net) How to start another program.

Answer: Process

40,Differences between datareader and Dataset

The biggest difference between datareader and dataset is that datareader always occupies sqlconnection and operates databases online .. any operation on sqlconnection will cause datareader exceptions .. because datareader only loads one piece of data in the memory each time, the occupied memory is very small .. because of the special nature and high performance of datareader. so datareader is only in .. after reading the first article, you cannot read the first article again ..

Dataset loads data in memory at one time. abandon database connection .. the database connection is abandoned after reading .. because dataset loads all data in the memory. therefore, memory consumption is relatively high... but it is more flexible than datareader .. you can dynamically Add rows, columns, and data. perform a back-to-back update operation on the database...

41,ADO.NetRelativeADOAnd other major improvements?

A: 1. ado.net does not rely on the ole db provider, but uses it.. Net-managed programs. 2: Do not use com3: do not support dynamic cursors and server-side games. 4: You can disconnect the connection and retain the current dataset. 5: strong type conversion. 6: XML support.

42,62-63 = 1 the equation is not true. Please move a number (the minus sign and the equal sign cannot be moved) so that the equation is true. How can we move it?

Answer: 62 is moved to the power 6 of 2.

43,In. Net (C # Or VB.net)Medium,Appplication. ExitOrForm. CloseWhat is the difference??

A: one is to exit the entire application, and the other is to close one of the forms.

44,In. net, all serializable classes are marked _____?

A: [serializable]

45,Main differences between XML and HTML

Answer: 1. XML is case-sensitive and HTML is not.

2. In HTML, if the context clearly shows where the paragraph or list key ends, you can omit the ending mark such as </P> or </LI>. In XML, the end mark cannot be omitted.

3. In XML, an element with a single tag but no matching ending tag must end with one/character. In this way, the analyzer does not need to find the end mark.

4. in XML, attribute values must be placed in quotation marks. Quotation marks are usable in HTML.

5. In HTML, You can have attribute names without values. In XML, all attributes must have corresponding values.

46,What is code-behind technology.

A: Code post-planting. Aspx, resx, and CS files. This is code separation. HTML code and server code are separated. easy to write and organize code. code separation is wise. It is uncomfortable to mix code into a pile like ASP. you can also understand that the HTML code is written at the front end, and the C # code is written at the back end. of course, there are also scripts and class calls at the front end, which can also be written together.

47,What are the common objects in ado.net? Describe them separately.

Answer: Connection database connection object

Command database commands

Datareader data reader

Dataset

48,What is XML?

A: The markup language can be expanded using XML. Extensible Markup Language. Tag refers to the information symbols that computers can understand. With this tag, computers can process various types of information.Article. To define these tags, you can select an international markup language, such as HTML, or use a markup language that is freely determined by people like XML. This is the scalability of the language. XML is simplified and modified from SGML. It mainly uses XML, XSL, and XPath.

49,What is the difference between datareader and dataset?

A: One is a read-only cursor and the other is a table in memory.

50,How many requests can be sent to the server?

A: Get and post. Get is generally the link mode, and post is generally the button mode.

51,How many stages are involved in the software development process? What is the role of each stage?

Answer: requirement analysis, architecture design, code writing, QA, and deployment

52,What does GAC mean?

A: Global Assembly cache.

53,How to handle hundreds of thousands of concurrent data records?

A: use stored procedures or transactions. When getting the maximum ID, update it at the same time. Note that the primary key does not have duplicate primary keys when it is not in auto increment mode. A stored procedure is required to obtain the maximum ID.

 

54,The elements in the set cannot be repeated. How can we identify whether the elements are repeated or not? Is = or equals () used ()? What are their differences?

A: The elements in the set cannot be repeated. Use the iterator () method to identify whether the elements are repeated or not. Equals () is used to determine whether two sets are equal.

The equals () and = Methods Determine whether the reference value points to the same object equals () is overwritten in the class, in order to return the true value when the content and type of the two separated objects match.

55,There is a return statement in try {}, so will the code in finally {} following this try be executed? When will it be executed, before or after return?

A: Yes. It will be executed before return.

56,Can I inherit the string class?

A: The string class is a final class, so it cannot be inherited.

57,Can constructor be overwritten?

A: constructor cannot be inherited, so overriding cannot be overwritten, but overloading can be overloaded.

58,Is run () or start () used to start a thread ()?

A: To start a thread is to call the START () method so that the virtual processor represented by the thread is runable, which means it can be scheduled and executed by JVM. This does not mean that the thread will run immediately. The run () method can generate the exit sign to stop a thread.

59,In. net, what does the accessory mean?

A: assembly. (Intermediate language, source data, resources, assembly list)

60,Which classes are required for reading and writing databases in. Net? What are their roles?

Answer: Dataset: data storage.

Datacommand: Execute the statement command.

Dataadapter: a collection of data.

61,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?

A: Generally, it is three layers.

Data access layer, business layer, and presentation layer.

The data access layer adds, queries, and modifies databases.

The business layer is generally divided into two layers. The business apparent layer communicates with the presentation layer, and the business rule layer Implements user password security.

The presentation layer adds a form to interact with users, for example, users.

Advantages: clear division of labor, clear organization, easy debugging, and scalability.

Disadvantage: increase costs.

62,The similarities and differences between UDP and TCP connections.
A: the former is only transmitted, no matter the data cannot be reached, no connection is required. The latter ensures that the transmitted data is accurate and must be linked.

63,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.
Msdn2005 explains this as follows:
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.

64,What isUser Controls in Asp.net
A: The user control is. the ascx extension can be dragged to different pages for calling to save code. for example, login may be available on multiple pages and can be used as a user control, however, one problem is that the relative paths of the images in the directories after the user control is dragged to different levels will become inaccurate, and you need to adjust them by writing your own methods.

65,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. 

66,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.

 

Reference: http://www.cnblogs.com/huikof/archive/2009/02/28/960939.html

Http://www.cnblogs.com/weihai2003/archive/2008/10/24/1319003.html

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.