C # interview questions

Source: Internet
Author: User
Tags dot net dot net framework

1. in C #, use text or images to describe the differences between string str = null and string str =.
Key answer: Describe the detailed space allocation. (10 points)
A: string str = null indicates that no memory space is allocated to it, while string str = "" indicates that it is allocated with a memory space of a null string.

2. Describe the similarities and differences between classes and struct in dotnet: (10 points)
A: The Class can be instantiated. It belongs to the reference type and is allocated to the memory stack. Struct belongs to the value type and is allocated to the memory stack.

3. Based on the delegate knowledge, complete the following code snippets in the user control: (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 ))

{
// Complete the following code to call the OnNew event of the OnDBOperate delegate signature.

}

}

}

A: if (OnNew! = Null)
OnNew (this, e );

4. Analyze the following code to complete the blanks (10 points)
String strTmp = "abcdefg ";
Int I = System. Text. Encoding. Default. GetBytes (strTmp). Length;
Int j = strTmp. Length;
After the above code is executed, I = j =

Answer: I = 13, j = 10

5. In the SQLSERVER server, there are two field IDs and LastUpdateDate in the given table 1. The ID indicates the updated transaction number, and the LastUpdateDate indicates the server time during the update, use an SQL statement to obtain the last updated transaction number. (10)

A: Select id from table1 Where LastUpdateDate = (Select MAX (LastUpdateDate) FROM table1)

6. Based on the knowledge of thread security, analyze the following code. Will the deadlock occur when I> 10 is called when the test method is called? And briefly explain the reasons. (10 points)

Public void test (int I)

{
Lock (this)
{
If (I> 10)

{

I --;

Test (I );

}

}

}

A: No deadlock will occur (but one int is passed by value, so each change is only a copy, so no deadlock will occur. But if you replace int with an object, the deadlock will occur)

7. 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 correctly use the connection pool?

Answer: If the input connectionString is the same, you can use the connection pool correctly. But exactly the same means that the numbers of spaces in the hyphen are in the same order.

2) can all exceptions in the test method be captured and displayed in the exception handling method used by the above Code?

A: You can only catch exceptions in database connections. (In finally, catch, if there are other operations that may cause exceptions, try and catch should also be used. So theoretically not all exceptions will be caught .)

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

A: WS uses HTTP to penetrate the firewall. Remoting can improve the efficiency by using TCP/IP and binary transmission.

9. The company requires the development of an inheritance System. windows. forms. listView components require the following special features: When you click the headers of columns in the ListView, all rows in the view can be rearranged based on the values of each row in the click column (the sorting method is similar to that in the DataGrid ). Based on your knowledge, please briefly discuss your ideas: (10)

A: Based on the column header clicked, the ID of this column is taken out, sorted by the ID, and bound to the ListView

10. Specify the following XML file to complete the algorithm flowchart. (10)

<FileSystem>
<DriverC>
<Dir DirName = "MSDOS622">
<File FileName = "Command.com"> </File>
</Dir>
<File FileName = "MSDOS. SYS"> </File>
<File FileName = "IO. SYS"> </File>
</DriverC>
</FileSystem>

Draw a flowchart that traverses all file names (FileName) (use recursive algorithms ).

A:
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 );
}

}

Simply put, the system traverses the root node and finds the child node.

 

1. Select fill in blank questions (2 points for each blank question, totally 60 points)
1. Select () when operating the SQL Server database ().
A) SQL Server. NET Framework data provider;
B) OLE DB. NET Framework data provider;
C) ODBC. NET Framework data provider;
D) Oracle. NET Framework data provider;
2. Among the following options, () is the reference type.
A) enum type
B) struct type
C) string type
D) int type
3. Which of the following statements about the hidden code files in ASP. NET is true ()
A) the logic of a Web form page program consists of Code. The Code is created to interact with the form. The programming logic is unique in a file that is different from the user interface. This file is called a "code hidden" file. If it is created in C #, it will have the ". ascx. cs" extension.
B) The code hidden files on all Web forms pages in the project are compiled into. EXE files.
C) The code hidden files of all Web forms pages in the project are compiled into the dynamic link library (. dll) file of the project.
D) None of the above are correct.
4. Which of the following statements is false ()
A) abstract classes are supported in C ++ but not in C.
B) In C ++, class members can be declared in header files and class members can be defined in CPP files. in C #, class members are declared and defined at the same place without header files.
C) in C #, you can use the new modifier to explicitly hide the members inherited from the base class.
D) in C #, Override must be added before the virtual functions of the base class to be redefined in the derived class.
5. C # data types include ()
A) value type and call type;
B) Value Type and reference type;
C) reference type and link type;
D) link type and call type;
6. Which of the following statements is false ()
A) the class cannot be inherited multiple times, but the interface can;
B) abstract classes can define members, but interfaces cannot;
C) abstract classes and interfaces cannot be instantiated;
D) A class can have multiple base classes and multiple base interfaces;
7. How to load an XML document in the DOM ()
A) save Method
B) load Method
C) loadXML Method
D) send Method
8. Which of the following statements about constructors is true ()
A) constructors can declare the return type.
B) The constructor cannot be modified using private.
C) The constructor must be the same as the class name.
D. The constructor cannot contain parameters.
9. The following are some enumeration definitions in C #. The incorrect usage is ()
A) public enum var1 {Mike = 100, Nike = 102, Jike}
B) public enum var1 {Mike = 100, Nike, Jike}
C) public enum var1 {Mike =-1, Nike, Jike}
D) public enum var1 {Mike, Nike, Jike}
10. int [] [] myArray3 = new int [3] [] {new int [3] {5, 6, 2}, new int [5] {6, 9, 7, 8, 3 }, new int [2] {3, 2 }}; the value of myArray3 [2] [2] is ().
A) 9
B) 2
C) 6
D) Cross-border
11. An interface is a reference type. You can declare () in the interface, but cannot declare public domains or private member variables.
A) methods, attributes, indexers, and events;
B) methods, attribute information, and attributes;
C) Indexer and field;
D) Events and fields;
12. In the ASP. NET Framework, server controls are specially designed to work with Web forms. There are two types of server controls ()
A) HTML controls and Web controls
B) HTML controls and XML controls
C) XML controls and Web controls
D) HTML controls and IIS controls
13. In ASP. NET, register a user control on the Web forms page and specify the control name as "Mike". The correct registration command is ()
A) <% @ Register TagPrefix = "Mike" TagName = "Space2" Src = "myX. ascx" %>
B) <% @ Register TagPrefix = "Space2" TagName = "Mike" Src = "myX. ascx" %>
C) <% @ Register TagPrefix = "SpaceX" TagName = "Space2" Src = "Mike" %>
D) None of the above
14. In ADO. NET, the following statements about the ExecuteNonQuery () method and ExecuteReader () method of the Command object are false ().
A) SQL statements for insert, update, delete, and other operations are mainly executed using the ExecuteNonQuery () method;
B) ExecuteNonQuery () method returns the number of rows affected by SQL statement execution.
C) the SQL statement of the Select operation can only be executed by the ExecuteReader () method;
D) The ExecuteReader () method returns a DataReder object;
15. The following ASP. NET Statement (B) correctly creates a connection with the SQL Server 2000 database.
A) SqlConnection con1 = new Connection ("Data Source = localhost; Integrated Security = SSPI; Initial Catalog = myDB ");
B) SqlConnection con1 = new SqlConnection ("Data Source = localhost; Integrated Security = SSPI; Initial Catalog = myDB ");
C) SqlConnection con1 = new SqlConnection (Data Source = localhost; Integrated Security = SSPI; Initial Catalog = myDB );
D) SqlConnection con1 = new OleDbConnection ("Data Source = localhost; Integrated Security = SSPI; Initial Catalog = myDB ");
16. Which of the following statements about the properties and events of the ToolBar Control in Winform is false ().
A) The Buttons attribute indicates all ToolBar Buttons of the ToolBar Control.
B) The ButtonSize attribute indicates the size of the ToolBar buttons on the ToolBar control, such as the height and width.
C) The DropDownArrows attribute indicates whether to display the down arrow keys next to the toolbar button (which has a column value that needs to be displayed in the following PULL mode ).
D) The ButtonClick event is triggered when you click anywhere on the toolbar.
17. When executing a stored procedure in ADO. NET, if you want to set the output parameters, you must set both the direction and () of the parameters and the parameter size if necessary.
A) size;
B) upper limit;
C) Initial value;
D) type;
18. If you set FormBoderStyle of the form to None ().
A) The form does not have borders and cannot be adjusted;
B) The form does not have a border but can be adjusted;
C) The form has borders but cannot be adjusted;
D) The form is transparent;
19. If you want to set the form to transparent ()
A) set the FormBoderStyle attribute to None;
B) set the Opacity attribute to a value smaller than 100%;
C) set the locked attribute to True;
D) set the Enabled attribute to True;
20. Which of the following statements about the indexer in C # is true ()
A) The index must have two or more parameters.
B) The indexer parameter type must be integer.
C. The indexer has no name.
D) None of the above
21. Which of the following statements is false ().
A) The form is also a control;
B) The form is also a class;
C) controls are inherited from forms;
D) The parent class of the form is the control class;
22. To operate the registry, you must include ().
A) System. ComponentModel namespace;
B) System. Collections namespace;
C) System. Threading namespace;
D) Microsoft. Win32 namespace;
23. To create a multi-document application, set the () attribute of the form to true.
A) DrawGrid;
B) ShowInTaskbar;
C) Enabled;
D) IsMdiContainer;
24. If treeView1 = new TreeView () is set, treeView1.Nodes. Add ("Root Node") returns a value of the () type.
A) TreeNode;
B) int;
C) string;
D) TreeView;
25. Which of the following statements about XML is false ().
A) XML provides a method to describe structured data;
B) XML is a simple, platform-independent and widely used standard;
C) XML documents can carry various types of information;
D) XML is only used to generate structured documents;

 

 

 

 

 

 

 

1. What are the differences between property and attribute in C #? What are their respective uses? What are the advantages of this mechanism?
2. Let's talk about the web service you understand. In the dot net framework, how can we combine xml well? (Just talk about the concept)
3. What are the characteristics of C #, Java, and c ++? What are the similarities and differences between C # and java?
4. C # Can I perform direct operations on the memory? (This is a difficult issue? Note !)
5. How to combine the unmanaged code written in Visual C ++ 6.0 with other dot net component in CLR?
6. Some previous projects? Introduce your programming experience. (This is not confusing. It is true or false when you first ask)
7. What do you expect from the company? What are your salary expectations? Why computer science? Previous work experience (which is very important )?

Q3: Maintain database integrity and consistency. Do you like to use triggers or write business logic? Why?
Q4: ADO. What are the main improvements to NET over ADO?
Q5: ASP. NET compared with ASP, what are the main advances?
Q6: What is the delegate in C? Is an event a delegate?
Q7: describes the implementation process of the indexer in C #. Can indexes be performed only by numbers?
Q8: How does one implement a class that supports FOREACH traversal in C?
Q10: Write an HTML page to implement the following functions: "Hello" is displayed when you click the page with the left-click button, and "disabled right-click" is displayed when you right-click the page ". The page is automatically closed in 2 minutes.
Q11: Do you know about XMLHTTP and WEBSERVICE? Briefly describe its features and functions
Q12: What is the difference between an interface and an abstract class? What is the basis for using interfaces and abstract classes?
Q13: What are the similarities and differences between custom controls and general user controls? If you want to use either of the two, which one do you choose? Why?
Q14: Describe ASP. NET Server Control Lifecycle
Q15: UML
Q16: object-oriented concept, Main Features
Q17: basis for classification. Class granularity issues
Q18: Transaction Management Problems

First, let's talk about the differences between final, finally, and finalize.
Second, can Anonymous Inner Class (Anonymous internal Class) be extends (inherited) other classes, or implements (implemented) interface (interface )?
Third, the difference between Static Nested Class and Inner Class is that the more you say, the better (the more general the interview questions are ).
Fourth, the difference between & and.
Fifth, the difference between HashMap and Hashtable.
Sixth, the difference between Collection and Collections.
7. When to use assert.
Eighth, what is GC? Why does GC exist?
Ninth, String s = new String ("xyz"); how many String objects are created?
10. How much is Math. round (11.5? Math. round (-11.5) and so on?
11th, short s1 = 1; s1 = s1 + 1; what is the error? Short s1 = 1; s1 + = 1; what is the error?
12th. What is the difference between sleep () and wait?
13th. Does Java have a goto?
14th, does the array have the length () method? Does String have the length () method?
15th, the difference between Overload and Override. Can the Overloaded method change the type of the returned value?
16th. 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?
17th. Give me the most common runtime exception.
18th, what is the difference between error and exception?
19th, List, Set, and Map are inherited from the Collection interface?
20th. What is the difference between abstract class and interface?
21st can abstract methods be both static, native, and synchronized?
22nd. Can an interface inherit an interface? Can an abstract class implement the (implements) interface? Can an abstract class inherit a concrete class )?
23rd. Is run () or start () used to start a thread ()?
24th. Can Constructor be overwritten?
25th. Can I inherit the String class?
26th. After a thread enters a synchronized method of an object, can other threads access other methods of this object?
27th, 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?
28th. Programming question: how many equals 2x8 in the most efficient way?
29th, the two objects have the same value (x. equals (y) = true), but different hash codes are available, right?
30th. After an object is passed as a parameter to a method, this method can change the attributes of the object and return the changed result, so is it a value transfer or a reference transfer?
31st. Does swtich work on byte, long, and String?
32nd programming question: Write a Singleton.

Database:

1. Differences between stored procedures and functions
2. What is a transaction?
3. What is the role of a cursor? How do I know that the cursor has reached the end?
4. triggers are divided into pre-trigger and post-trigger. There are differences between these two triggers. What is the difference between statement-level triggering and row-level triggering.

1. Use C # to implement the following functions
A generates an int array with a length of 100 and inserts 1-100 randomly into the array, which cannot be repeated.
B sorts the array generated above, which must be in ascending or descending order.
2. Describes several common methods for passing parameters between pages in. net and their advantages and disadvantages.
3. Describe the error handling mechanism in. net and give an example.
4. Please describe the meaning of a strong name
5. List several cycles in c # and point out their differences
6. Indicate all types of base classes in. net
7. Indicate the meaning of GAC
8. In SQL SREVER, new data is inserted into a table, and how to quickly obtain the current value of the Self-increment Field

Under what circumstances will you use the virtual method? What is the difference between it and the interface?
Q: What is the difference between Override and overload?
Q: What is the difference between the value type and the reference type?
Q: How do I understand static variables?
Q: How many requests can be sent to the server?
Q: What is the difference between DataReader and Dataset?
Q: If you need to pass variable values in a B/S system, but you cannot use Session, Cookie, and Application, how can you handle them?
Q: How many layers of B/S structure do you use. net for development? What is the relationship between each layer and why do you need to layer it like this?
Q: How many stages are there in the software development process? What is the role of each stage?
Q: Microsoft has launched a series of Application blocks. What are the Application blocks you know and their functions?
Q: Please list some of the design patterns you have used and when to use them?
Q: What do you know about WebService?
Q: How are you interested in programming? How can I solve problems that I don't understand at work? How do you improve your programming skills?
Q: Why did you leave?
Q: How do I pass Chinese parameters through hyperlinks?
Q: Please program all TextBox controls on the page and assign it a string. Empty?
Q: How can I program a Bubble sorting algorithm?

1. Differences between override and overload
2. What is the error handling mechanism of. net?
3. Similarities and Differences between interfaces and classes in C #
4. Differences between DataReader and DataSet

1. Which of the following methods can be used to access the member functions and attributes of the other class? For more information, see.
2. If you need to record the number of instances of the class, write a simple class to prove how to implement it.
3. 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.
4. 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.

I. Fill in blank questions
Where is the ternary operator in 1. c __? :___?
2. When integer a is assigned to an object, integer a will be _ packed (encapsulated )___?
3. Which of the following types of Class Members are accessible? This.; new Class (). Method;
4. public static const int A = 1; is this Code incorrect? What is it? Const cannot be modified using static
5. float f =-123.567F;
Int I = (int) f;
Which of the following is the I value _____? 123
6. I used operator to declare and only declared "=". Is there any error?
7. What is the keyword of the delegate statement ______? Delagete
8. What are the characteristics of classes modified with sealed? Sealed and cannot inherit
9. All Custom User Controls in Asp.net must inherit from ________? Control
10. In. Net, all serializable classes are marked _____?
11. In. Net hosting code, we don't have to worry about memory vulnerabilities. This is because ______? Gc
12. Are there any errors in the following code? _______
Using System;
Class
{
Public virtual void F (){
Console. WriteLine ("A.F ");
}
}
Abstract class B:
{
Public abstract override void F (); // new public abstract void F ();
}

13. when class T only declares the constructor of a private instance, ___ can ___ (can or cannot) derive a new class from T outside the program text of T, it is not allowed to create any instance of T directly (either or not.
14. Is there any error in the following code?
Switch (I ){
Case ():
CaseZero ();
Break;
Case 1:
CaseOne ();
Break;
Case 2:
Dufault; // wrong
CaseTwo ();
Break;
}
15. Can System. Web. UI. Page be inherited in. Net? Yes

Ii. Short answer
1. What are the meanings of using and new keywords in c? Using command and statement new create instance new hide methods in base class
4. What are the differences between classes and structures? The class is a reference type and the structure is a value type.
5. a string of 10000 characters is randomly extracted from a-z to form a string of 10000 characters. Use c # To write the main program.
6. For such an enumeration type:
Enum Color: byte {
Red,
Green,
Blue,
Orange
}
String [] ss = Enum. GetNames (typeof (Color ));
Byte [] bb = Enum. GetValues (typeof (Color ));
Test a program to display all the symbol names defined in the enumeration type and their corresponding values.
7. Do you know the design mode? List the names of the design patterns you know. //
8. set a table in SQL Server to save the tree structure of the organization chart (assuming that only the name is required in the structure chart). If I want to query all the positions under a certain position, what are your ideas about using a stored procedure?
9. What is SQL injection and how to prevent it? For example.
10. 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 ");
// Not equal because the object is compared

1. Write a method to flip a string and add some conditions, such as "," and ".", to design and test its use case.
2. Design a test case for a paper cup (it can be a cup in a broad sense, not necessarily a cup with a specific function)
Development language concepts
3. What is reflection?
4. How to Write Design Patterns with Singleton
5. What is the garbage collection mechanism in C?
6. What is Application Pool?
7. What are the advantages and disadvantages of the differences between linked lists and arrays.
8. How to Implement Remoting on the client server?
9. What is a friend function?
10. How to Implement polymorphism with standard C?
11. What is a virtual function?
12. What is an abstract function?
13. What is memory leakage? How can I determine whether a memory leak is detected in the simplest way?

English
14. The main functions of projects using C #/C ++ are described in English.
15. How do I communicate with American engineers if I want to hold a conference call with the US?
16. What would you do if the boss thinks your technology is lagging behind?

Database knowledge questions
17. Tools used to call stored procedures
18. What are the two indexes of SQL Server? What is the role of an index? What are the advantages and disadvantages of indexes?
19. Functions of triggers

Other knowledge questions and questions
20. What is Web Service?
21. What is XML?
22. How to Implement Socket?

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.