A summary of the key points around C # face questions

Source: Internet
Author: User

Believe that a lot of people who learn net want to know how to encounter C # (C # Training) face questions to do, in fact, encountered C # face questions do not have to panic, and most of the topics are around a few points. So when we review the C # face question, the following questions need to be detailed understanding.

1. In C #, string str = null and string str = "" Try to use text or an image to illustrate the difference.

Answer point: Explain the detailed spatial allocation. (10 points)

A: string str = NULL does not allocate memory space to him, and string str = "" Assigns it a memory space with an empty string length.

2. Please describe the similarities and differences between class and structure (struct) in dotnet: (10 points)

A: Class can be instantiated, is a reference type, is allocated on the heap of memory, the struct belongs to the value type, is allocated on the memory stack.

3, according to the knowledge of the delegate (delegate), complete the following code snippet in the user control to fill in: (10)

Namespace test

{public delegate void Ondboperate ();

public class UserControlBase:System.Windows.Forms.UserControl

{public event ondboperate onnew;

Privatevoidtoolbar_buttonclick (Objectsender,system.windows.forms.toolbarbuttonclickeventargs e)

{if (E.button.equals (btnnew))

{//Please use the following complement code to invoke the OnNew event for the Ondboperate delegate signature.

} } }

Answer: if (onnew! = null)

OnNew (this, e);

4. Analyze the following code to complete the blanks (10 points)

String strtmp = "ABCDEFG xxx";

int i= System.Text.Encoding.Default.GetBytes (strtmp). Length;

int j= strtmp.length;

After executing the above code, i= j=

Answer: i=13,j=10

5. SQL Server, there are two field IDs in the given table Table1, Lastupdatedate,id represents the updated transaction number, Lastupdatedate represents the server time when updating, use a SQL statement to obtain the last updated transaction number. (10)

Answer: SELECT ID

From table1

WHERE lastupdatedate = (SELECT MAX (lastupdatedate) from table1)

6, according to the relevant knowledge of thread safety, analyze the following code, when the test method is called when the i>10 will cause a deadlock? And briefly explain the reasons. (10 points)

public void Test (int i)

{Lock (this)

{if (i>10)

{i--;

Test (i);

} } }

A: There is no deadlock, but a bit of int is passed by value, so each change is just a copy, so there is no deadlock. But if you change int into an object, the deadlock will happen.)

7,C # face question : Analyze the following code. (10)

public static void Test (String connectstring)

{System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection ();

Conn. ConnectionString = connectstring;

Try

{Conn. Open ();

. }catch (Exception Ex)

{MessageBox.Show (ex.tostring ());

}finally

{if (!conn. State.equals (connectionstate.closed))

Conn. Close ();

}

Excuse me

1) Can the above code use connection pooling correctly?

Answer: If the incoming connectionstring is identical, the connection pool can be used correctly. But the exact same meaning is that the number of spaces in the hyphen is exactly the same as the order.

2) The exception handling method used by the above code, whether all exceptions within the test method can be captured and displayed?

A: You can only catch exceptions in a database connection. (Finally, in catch, you should use Try,catch if there are other actions that might throw an exception.) So theoretically not all anomalies will be captured. )

8. Briefly discuss your understanding of the two technologies of remoting and webservice under the Microsoft. NET Framework and the practical applications. (10)

A: WS is primarily available with HTTP, penetrating firewalls. and remoting can use TCP/IP, binary delivery to improve efficiency.

9, the company requires the development of an inherited System.Windows.Forms.ListView class of components, requirements to achieve the following special features: When you click the ListView column header, you can rearrange all the rows in the view by clicking each row of columns ( Sort the same way as a DataGrid). Based on your knowledge, please briefly discuss your ideas: (10)

A: Depending on the column header of the click, the ID of the package is taken out, sorted by that ID, in the binding to the ListView

10, given the following XML file, complete the algorithm flowchart. (10)

< DRIVERC >

Please draw a flowchart that iterates through all filenames (using the recursive algorithm).

For:

void FindFile (Directory D)

{fileorfolders = D.getfileorfolders ();

foreach (Fileorfolder fof in Fileorfolders)

{if (FoF is File)

You Found a file;

else if (FoF is Directory)

FindFile (FOF);

}} is simply to walk from the root node to find the child node, find its child node from the found child node, a layer down

The above is the C # face question in the focus of the type of topic, master these topics on our help is still very large, so we review C # face questions , to do a detailed understanding of these topics, hope to help you.

A summary of the key points around C # face questions

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.