. NET written questions

Source: Internet
Author: User
Tags closing tag

What is the use of 2.1.using keywords? What is IDisposable?

The using can declare the introduction of namespace, and can also implement the release of unmanaged resources, implement the Idisposiable class in the using, and automatically invoke the Dispose method of the object when the using ends, freeing the resource. Using is actually equivalent to try......finally, which is more convenient to use.

2.2.assembly.load ("Foo.dll"); Is this sentence correct?

Error, the correct one should be Assembly.Load ("foo"); or Assembly.LoadFrom ("Foo.dll");

The main difference between 2.3.XML and HTML

(1) XML is case-sensitive, HTML is not distinguished.

(2) in HTML, if the context clearly shows where the paragraph or list key ends, you can omit the end tag such as </p> or </li>. In XML, you must never omit the end tag.

Html:<br><br>

Xml:</img><br/><br/>

(3) in XML, an element that has a single tag without a matching closing tag must end with A/character. This way the parser knows not to look for the end tag.

(4) in XML, attribute values must be enclosed in quotation marks. In HTML, the quotation marks are available for use.

(5) In HTML, you can have a property name without a value. In XML, all attributes must have corresponding values.

XML is used to store and transfer data, and HTML is used to display the data

2.4.string str = NULL with string str = "" describes the difference.

A: string str = NULL does not allocate memory space to him, and string str = \ "\" assigns it a memory space with an empty string length. string str = NULL no string object, String str = "" has a string object.

2.5. Write out an SQL statement: Take the 31st to 40th record in table A (SQL Server, with the auto-growing ID as the primary key, note that the ID may not be contiguous. )

Answer: 1:select top * from a where ID not in (select top IDs from a)

Solution 2:select Top * from a Where ID > (select MAX (ID) from (select top with ID from a) as A)

Solution 3:select Id,row_number () over (order by ID) as RowNum from A where rowNum between and 40 (recommended)

2.6. The object-oriented language has ________. _________. ________ Sex

Answer: encapsulation. Inheritance. Polymorphism.

2.7. All serializable classes in. NET are marked as _____?

Answer: [Serializable]

2.8. We don't have to worry about memory leaks in. NET managed code, because we have ___?

Answer: GC.

2.9. What is an application domain? What is a regulated code? What is managed code? What is a strongly typed system? What are crates and unboxing? What is overloading? Cts. What are the CLS and CLR explanations for each?

The application domain is security. Reliability. Versioning and uninstalling assemblies provide an isolation boundary. Application domains are typically created by the runtime host, which is responsible for booting the common language runtime before running the application. application domains provide a more secure, more versatile processing unit that the common language runtime can use to provide isolation between applications.

Regulated code: Any code that runs in the. NET environment is controlled code (managed). NET external code is also running on Windows, which is called an unregulated code (unmanaged).

Code developed using a language compiler based on the common language runtime is called managed code, and managed code has many advantages, such as cross-language integration. Cross-language exception handling. Enhanced security. Version control and deployment support. Simplified component Interaction Model-debugging and Analysis Services.

A strongly typed language is a language that can prohibit any code that violates a type system, or that is capable of capturing all errors that violate a type system. We say that C + + is strongly typed in C + +, because C + + prohibits implicit conversions in C, such as converting void* to arbitrary pointer types.

Boxing and unpacking enable value types to be treated as objects. Boxing a value type packages the value type into an instance of the Object reference type. This allows value types to be stored in the garbage-collected heap. Unpacking will extract the value type from the object.

Each type member has a unique signature. A method signature consists of a method name and a list of parameters (the order and type of the parameters of the method). Multiple methods with the same name can be defined within a type as long as the signature is different. When you define two or more methods that have the same name, they are called overloads.

CTS Common type systems (common type System)

A specification that determines how the common language runtime defines. Use and manage types.

CLR Common language runtime

The. NET Framework provides a run-time environment called the common language runtime that runs code and provides services that make the development process easier.

CLS Common Language Specification

To fully interact with other objects, regardless of the language in which they are implemented, the object must expose to callers only the common functionality of all the languages that they must interoperate with. The common Language Specification (CLS) is defined for this purpose, which is a set of basic language features required by many applications.

2.10. What is Code-behind technology?

is code-behind, the separation of display logic and processing logic from the method of ASPX pages pointing to the CS file in ASP. This facilitates the creation of Web applications. such as division of labor, art and programming can be a dry, no longer like the previous ASP code and HTML code mixed together, difficult to maintain.

2.11. An interface is a reference type that can be declared in an interface. Properties. Indexers and events, but cannot declare public domain or private member variables.

2.12. In ADO, the ExecuteNonQuery () method and the ExecuteReader () method for the Command object are described below (c).

A) SQL statements such as Insert.update.delete are performed mainly with the ExecuteNonQuery () method;

b) The ExecuteNonQuery () method returns the number of rows affected by the execution of the SQL statement.

c) The SQL statement for the select operation can only be performed by the ExecuteReader () method;

D) the ExecuteReader () method returns a Datareder object;

Answer: Executescalar→select getdate ().

2.13. The following about the indexer in C # is understood correctly (c)

A) The parameters of the indexer must be two or more than two

b) The parameter type of the indexer must be an integer type

c) Indexer has no name

D) above are not

2.14. To create a multi-document application, you need to set the (d) property of the form to true.

a) DrawGrid;

b) ShowInTaskbar;

c) Enabled;

d) IsMdiContainer;

2.15. If Treeview1=new TreeView () is set, TREEVIEW1.NODES.ADD ("root node") returns a value of type (a).

a) TreeNode;

b) int;

c) string;

d) TreeView;

2.16. The following description of the XML error is (d).

A) XML provides a way to describe structured data;

b) XML is a simple. Platform-independent and widely adopted standard;

c) XML documents can carry a variety of information;

d) XML is just for the purpose of generating structured documents;

2.17. The following C # code attempts to define an interface:

public interface Ifile{int A;int Delfile () {   A = 3;} void Disfile ();}

For the above code, the following description is incorrect (d).

A) errors in the above code include: The variable cannot be defined in the interface, so the int a code line will appear error;

b) Errors in the above code include: The interface method Delfile is not allowed to implement, so can not write a specific implementation function;

c) code void Disfile (); Declaration error-Free, interface can have no return value;

d) code void Disfile (); should be written as void Disfile () {}; null and NULL are not the same.

2.18. There is a button control in ASP. MyButton, if you click the control, navigate to the other page http://www.abc.com, the correct code is (c).

A) private void MyButton_Click (object sender, System.EventArgs e) {Redirect ("http://www.abc.com");}

b) private void MyButton_Click (object sender, System.EventArgs e) {request.redirect ("http://www.abc.com");}

c) private void MyButton_Click (object sender, System.EventArgs e) {reponse.redirect ("http://www.abc.com");}

d) private void MyButton_Click (object sender, System.EventArgs e) {request.redirect ("http://www.abc.com"); return true;}

2.19. Declare a delegate public delegate int mycallback (int x); The prototype of the callback method that is produced with the delegate should be (b).

a) void mycallback (int x);

b) int receive (int num);

c) string receive (int x);

D) uncertain;

What is the difference between 2.20.StringBuilder and String?

A: String in the operation (such as assignment. splicing, etc.) will produce a new instance, and StringBuilder will not. So it's best to use StringBuilder when a large number of string concatenation or frequent manipulation of a string, do not use string

If you want to manipulate a growing string, try not to use the string class instead of the StringBuilder class. Two classes work differently: The String class is a traditional way of modifying a string, and it does work to add a string to another string. Yes, but in. NET Framework, this operation is really not a row. Because the system first writes two strings to memory, then deletes the original string object, creates a string object, and reads the data in memory to the object. This carefree matter, it took a lot of time. This is not the case with the StringBuilder class under the System.Text namespace, which provides a append method that can be used to modify the string in place of an existing object, simply and directly. Of course, the difference between these two efficiencies is not generally noticeable, but if you are going to do a lot of adding to a string, the time and string classes that the StringBuilder class consumes are simply not an order of magnitude.

2.21. Please describe the difference between the attribute and the indexer.

Properties Indexer

identified by name. identified by signature.

Accessed through a simple name or member access. Accessed through element access.

Can be a static member or an instance member. Must be an instance member.

The get accessor for the property has no parameters. The get accessor of the indexer has the same formal parameter list as the indexer.

The set accessor of a property contains an implicit value parameter. In addition to the value parameter, the indexer's set accessor has the same formal parameter list as the indexer.

2.22. Please describe the difference between const and readonly.

The const keyword is used to modify the declaration of a field or local variable. It specifies that the value of a field or local variable cannot be modified. A constant declaration introduces one or more constants of a given type.

The declaration of a const data member must contain an initial value, and the initial value must be a constant expression. Because it is at compile time it needs to be fully evaluated.

A const member can be initialized with another const member, provided there is no cyclic dependency between the two.

The readonly evaluation assignment at run time allows us to defer the initialization of object to run time while ensuring "read-only access".

The ReadOnly keyword differs from the CONST keyword: the const field can only be initialized in the declaration of the field. The readonly field can be initialized in a declaration or constructor. Therefore, depending on the constructor used, the ReadOnly field may have different values. In addition, the Const field is a compile-time constant, and the ReadOnly field can be used to run a constant number.

ReadOnly can only be initialized at declaration time or in constructors, and cannot be inside the constructor of the static modifier.

Resources:

Http://www.cnblogs.com/royenhome/archive/2010/05/22/1741592.html

Http://www.cnblogs.com/jams742003/archive/2010/03/23/1692913.html

Http://www.cnblogs.com/wayfarer/archive/2006/04/27/386658.html

2.23. Please explain the ASP. What is the relationship between a Web page in net and its hidden class?

An ASP. NET page typically corresponds to a hidden class, which is typically specified in the declaration of an ASP. Page declaration of a hidden class such as a page tst1.aspx the following

<%@ page language= "C #" codebehind= "Tst1.aspx.cs" autoeventwireup= "false" inherits= "T1.tst1"%>

Codebehind= "Tst1.aspx.cs" indicates which code file is used when compiling this page, which hidden class is used by the inherits= "t1.tst1" Table with runtime

2.24. What is viewstate, can I disable it? Are the controls you use disabled?

ViewState is a mechanism for saving States, and the EnableViewState property is set to False to disable. The most powerful example: Label.textbox after disabling viewstate different performance to illustrate.

2.25. What is your experience with Web service?

A: If you write some of the programs you want others to use through the Web services, you can also write their own methods labeled [webmethed] to implement Web services. [is when writing a program, you want to implement some other sites have been implemented, but also with Web services to be visualized as an XML language encoding. You can use the XML generated by someone else's code to find the information you need to implement some of the functions of the program you write.

2.26. Under what circumstances do you use virtual methods? How does it differ from the interface?

Answer: When a subclass re-defines a method of a parent class, the method of the parent class must be defined as virtual

There cannot be a method body in the definition interface, the virtual method can.

When implemented, subclasses can not redefine virtual methods, but if a class inherits an interface, that interface must be implemented.

2.27. Indefinite selection:

(1) The following description is correct: B C

A. There can be virtual methods in the interface. B. A class can implement multiple interfaces. C. The interface cannot be instantiated. D. The interface can contain implemented methods.

(2) Read the records from the database, you may use the method is: B C D

A. ExecuteNonQuery b. executescalar C. Fill D. ExecuteReader

(3) For a class that implements the IDisposable interface, which of the following can perform application-defined tasks related to releasing or resetting unmanaged resources? (Multiple selection) (ABC)

a.close b.dispose c.finalize D.using E.quit

(4) Which of the following descriptions of ref and out are correct? (Multiple selection) (ACD)

A. With the ref parameter, the arguments passed to the ref parameter must be initialized first.

B. With the out parameter, the arguments passed to the out parameter must be initialized first.

C. With the ref parameter, the parameter must be passed explicitly to the method as a ref parameter.

D. With the out parameter, the parameter must be passed explicitly to the method as an out parameter.

2.28. Single choice:

(1) The following options, (C) are reference types.

A) enum type B) struct type c) string type d) int type

(2). Description of the code-behind file in ASP. Correct is (C)

A) The logic of a Web Forms page's program consists of code that is created to interact with the form. The programming logic is unique in a file that differs from the user interface. The file is called a "code-behind" file, and if created in C #, the file will have a ". Ascx.cs" extension.

b) The code-behind files for all Web Forms pages in the project are compiled into an. exe file.

c) The code-behind files for all Web Forms pages in the project are compiled into a project dynamic link library (. dll) file.

D) above are not correct.

(3). The following description is incorrect (D)

A) The class cannot have multiple inheritance and interface can;

b) The abstract class itself can define members and interfaces can not;

c) Abstract classes and interfaces are not instantiated;

D) A class can have multiple base classes and multiple base interfaces;

What are the similarities and differences between 2.29.DataReader and datasets?

DataReader Always use SqlConnection, online operation database, each time only in memory load a piece of data, so the memory is very small, is only in. Read-only

A dataset loads data into memory at once. Discard database connections. After reading, the database connection (non-connected mode) is discarded, and all the data is loaded in memory. So the comparison consumes memory ... But be more flexible than DataReader. You can dynamically add rows, columns, and data. Callback Update operation for database (dynamic operation of data read into memory)

2.30.public static const; int a = 1; Is this code wrong?

Error: const cannot be decorated as static, because it is statically when defined as a constant (const).

2.31. What is the execution result of the following program?

int i = 10; Console.WriteLine (i++); Console.WriteLine (++i); Console.WriteLine (I=20);

Answer:

10

12

20

2.32. Which of the following nouns is not directly related to webservice? B

A, UDDI

B, GUID

C, WSDL

D, SOAP

Soap and HTTP relationships: SOAP is based on HTTP protocol, and unlike normal Web pages, Web pages return html,soap are XML data that conforms to the SOAP protocol.

2.33. What is the execution result of the following program?

int i = 10;if (i <=0); Console.WriteLine ("I must be greater than 0"); Console.WriteLine ("OK");

Answer:

I must be greater than 0

Ok

Answer: Note that if (I <=0) the ";", because of the ";", so that Console.WriteLine ("I must be greater than 0") is no longer part of the IF, but a separate statement. The same is true for a for loop.

2.34. What is the execution result of the following program?

static void Main (string[] args) {    Console.WriteLine (Calc ());    Console.readkey ();} static int Calc () {    int i = 0;    Try    {        return i;    }    Finally    {        Console.WriteLine ("finally");        i++;}    }

Answer:

Finally

0

Answer: Return executes first, finally executes, so the return value is 0 before the i++. Note that it is not return when the function really "returns, executes the end", return is only the token function return value is 0, the mark is finished will also execute the code in Finally, only finally the code after the completion of the function is really returned.

2.35. When the following options are not formed, the program that does not constitute a dead loop is (C)

A.int I=100;while (1) {i=i%100+1; if (i>100) break;}

B.for (;;);

C.int k=1000; do {++k;} while (k>=10000);

D.int s=36; while (s);--s;

2.36. Which of the following technologies is not related to database access technology (C)

A, SQLHelper

B, EnterPrise Library

C, AppDomain

D, Linq

2.37. Which of the following statements is wrong (AC)

A, to change the BMP format file to JPG is the easiest way to modify the image format

B, QQ dynamic expression displayed on the Web page with a GIF format is better

C, the BMP format pictures in the Web page can optimize the speed of the site

D, PNG format can be used in Web pages to achieve a transparent effect.

Answer: A, C. A error is because the suffix of the modified file does not really modify the format of the file, you want to use Photoshop, MSPaint and other image processing tools to convert. C errors are due to the inability to use BMP images in Web pages.

2.38, choose a simple description from the following abbreviations

OA (Office Automation): office automation

MIS (Managment Information System): Management Information System

HRM (Human Resource Managment): Human resources management, including employee management, payroll management, onboarding Management, exit management, reimbursement management, leave management, etc.

CRM (Customer Relation Managment): client Relationship management system, including customer management, customer care, customer visit, complaint management, consulting management, repair management, etc.

KM (Knowledge managment): knowledge Management

2.39. What is the execution result of the following program?

public struct point{public    int x;    public int y;    public point (int x, int y)    {        this.x = x;        This.y = y;    }} Point P1 = new Point (100, 100); Point P2 = p1;p1.x = 200; Console.WriteLine ("{0},{1}", p1.x, p2.x);

Answer:

200,100

Solution: The struct is copied and passed.

. NET written questions

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.