DOTNET (C #) Interview Questions

Source: Internet
Author: User
Tags dotnet

1. What are the differences between <% # %> and <%>?
<% # %> Indicates the bound data source.
<%> Is a server-side code block.
2. Can the following code be compiled? If not, correct the code and explain the cause.
<HTML>
<%
Int subtract (INT num1, int num2 ){
Return num1-num2;
}
%>
<Body>
<%
Int number = 100;
While (number> 0 ){
Response. Write ("value:" + number + "<br/> ");
Number = subtract (number, 1 );
}
%>
</Body>
</Html>
3. What functions can be implemented through the Web site administration tool (in vs2005? Which files will the web site administration tool modify or add automatically?
4. Explain the similarities and differences between data parameter with the "original _" prefix and data parameter without the prefix. (Simple code description is available)
5. Modify the following code segment to enable the gridview to update data.
<% @ Page Language = "C #" %>
<HTML>
<Head runat = "server">
<Title> gridview </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Asp: gridview id = "gridview1" allowsorting = "true" allowpaging = "true" runat = "server"
Performanceid = "sqldatasource1" datakeynames = "ID" autogeneratecolumns = "false">
<Columns>
<Asp: boundfield readonly = "true" headertext = "ID" datafield = "ID" sortexpression = "ID"/>
<Asp: boundfield headertext = "last name" datafield = "lname" sortexpression = "lname"/>
<Asp: boundfield headertext = "first name" datafield = "fname" sortexpression = "fname"/>
</Columns>
</ASP: gridview>
<Asp: sqldatasource id = "sqldatasource1" runat = "server"
Selectcommand = "select [ID], [lname], [fname] from [authors]"
Connectionstring = "<% $ connectionstrings: pubs %>"/>
</Form>
</Body>
</Html>
6. The gridview does not have the built-in insert data function. If you want to insert data in the gridview, what do you think?
7. Which of the following features of ASP. NET 2.0 are most exciting to you? Why? (You can also talk about C #2.0)
ASP. NET 2.0 highlights three concepts compared with 1.1,
1. Improve productivity
Masterpage)
B Member Management
C. Data Access
D. personalization
2. improvement in management capabilities (for example, Web. config)
3. Improved performance to meet the needs of more users
8. What is the biggest difference between ASP. NET 2.0 (vs2005) and the development tool you used earlier (. NET 1.0 or other? Which development ideas (pattern/architecture) were available on your previous platform?

To be transplanted to ASP. NET 2.0 (or already embedded in ASP. NET 2.0)

1 ASP. NET 2.0 encapsulates and packages some code, so it reduces a lot of code compared to the same function of 1.0.
2. Both the code separation and page embedding server-side code modes are supported. In the previous version 1.0 ,.. Net prompt help is only available in separated code files. You cannot embed server-side code on the page to get help tips,
3. When switching code and design interfaces, 2.0 supports cursor positioning.
4. When binding data, you can perform operations such as paging, update, and delete on tables in a visualized manner, facilitating beginners.
5. More than 40 new controls are added to ASP. NET, reducing the workload.

9. Send me the demo you have done during the learning process, or send the demo you have done to me in a project.

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

Override is used to override the method of the parent class. The method or operator with the same name has different types of parameters.

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

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.

Datareader is used to read data and dataset is used to save data in memory.

Differences between heavy load and coverage
1. the override of a method is the relationship between the subclass and the parent class, and the vertical relationship. the overload of a method is the relationship between 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.

4. 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...

 

I. Fill in blank questions
1. What is the ternary operator in C _____?
2. When integer a is assigned to an object, which of the following will integer a be assigned _____?
3. Which of the following types of Class Members are accessible?
4. Public static const int A = 1; is this Code incorrect? What is it?
5. Float F =-123.567f;
Int I = (INT) F;
Which of the following is the I value _____?
6. The operator statement is used and only = is declared. Is there any error?
7. What is the keyword of the delegate statement ______?
8. What are the characteristics of classes modified with sealed?
9. All Custom User Controls in Asp.net must inherit from ________?
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 ______?
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 ();
}

13. When class t only declares the private instance constructor, the class T's program text is external, ______ (either or not) from t

Derive a new class, ____ (can or cannot), and directly create any instance of T.
14. Is there any error in the following code?
Switch (I ){
Case ():
Casezero ();
Break;
Case 1:
Caseone ();
Break;
Case 2:
Dufault;
Casetwo ();
Break;
}
15. Can system. Web. UI. Page be inherited in. Net?

Ii. Short answer
1. What are the meanings of using and new keywords in C?
2. In the following example
Using system;
Class
{
Public (){
Printfields ();
}
Public Virtual void printfields (){}
}
Class B:
{
Int x = 1;
Int y;
Public B (){
Y =-1;
}
Public override void printfields (){
Console. writeline ("x = {0}, y = {1}", x, y );
}
What is the output when new B () is used to create B's instance?
3. In the following example

Using system;
Class
{
Public static int X;
Static (){
X = B .y + 1;
}
}
Class B
{
Public static int y = a.x + 1;
Static B (){}
Static void main (){
Console. writeline ("x = {0}, y = {1}", a.x, B .y );
}
}
What is the output result?
4. What are the differences between classes and structures?
5. A string of 10000 characters is randomly extracted from a-Z to form a string of 10000 characters. Use C # To compile the main program

.
6. For such an enumeration type:
Enum color: byte {
Red,
Green,
Blue,
Orange
}
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. (assume that only the name is included in the structure.

Need to save). If I want to query all the positions under a certain position and use a stored procedure, what do you think?
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 ");

1? :
2 packing
3 types
4. the const members are all static, so we should remove the static
5-123
6. You must modify equale and gethash () at the same time ()? If "=" is reloaded, it must be reloaded "! ="
7. Delegate
8 cannot be inherited
9 system. Web. UI. usercontrol
10 [serializable]
11 GC
12 abstract override cannot be modified together
13 No. No.
14 case (): no default;
15 Yes

1 using introduces a namespace, or automatically calls its idespose after a pair is used, new instantiates a pair

Such as, or modify a method, table this method completely overwrites this method,
2 x = 1, y = 0
3 x = 1, y = 2
4. One of the biggest differences is the reference type, and the other is the default value type.

. Net & C # basic knowledge questions (20%)
1. How to obtain the handle of the current form or control in. Net (C # Or VB.net), especially the handle of the control itself (Please list ).
Answer: This (C #) Me (VB.net ).

2. How to customize messages in. Net (C # Or VB.net) and process these messages in the form.
Answer:
Reload the defwndproc function in form to process messages:
Protected override void defwndproc (Ref system. winforms. Message m)
{
Switch (M. msg)
{
Case wm_lbutton:
/// The format function of string and cstring in MFC is used differently.
String message = string. Format ("Message received! Parameter: {0}, {1} ", M. wparam, M. lparam );
MessageBox. Show (Message); // display a message box
Break;
Case User:
Processed code
Default:
Base. defwndproc (ref m); // call the base class function to process non-custom messages.
Break;
}
}

3. How to start another program in. Net (C # Or VB.net.
Answer: Process

4. How to disable a form in. Net (C # Or VB.net.
Answer:
Private void form1_closing (Object sender, system. componentmodel. canceleventargs E)
{
E. Cancel = true;
}

5. What are the differences between appplication. Exit and form. Close in. Net (C # Or VB.net?
Answer: one is to exit the entire application, and the other is to close one form.

6. There is a double variable in C #, such as 10321.5, such as 122235401.21644. How to output the value as a currency according to the habits of different countries. For example, in the United States, $10,321.50 and $122,235,401.22 are used, while in the United Kingdom, the ratio 10 321.50 and the ratio 122 235 401.22
Answer:
System. Globalization. cultureinfo myculture = new system. Globalization. cultureinfo ("En-us ");
// System. Globalization. cultureinfo myculture = new system. Globalization. cultureinfo ("En-GB"); for the UK currency type
Decimal y = 9999999999999999999999999999 m;
String STR = string. Format (myculture, "My amount = {0: c}", y );

7. A password only uses five letters (K, L, M, N, and O). The words in the password are arranged from left to right. The password words must follow the following rules:
(1) the minimum length of a password word is two letters, which can be the same or different.
(2) K cannot be the first letter of a word.
(3) If l appears, more than once
(4) M cannot make the last or second-to-last letter
(5) If K appears, N must appear.
(6) If O is the last letter, l must appear
Question 1: Which of the following letters can be placed behind o in Lo to form a three-letter password word?
A) k B) L C) m d) N
Answer: B

Question 2: If the letters K, L, and m can be obtained, what is the total number of two letter-length password words?
A) 1 B) 3 C) 6 d) 9
Answer:

Question 3: Which of the following is the word password?
A) klln B) loml c) mllo d) nmko
Answer: c

8. 62-63 = 1 the equation is not true. Please move a number (do not move the minus sign or equal sign) so that the equation is true. How do you move it?
Answer: 62 is moved to the power 6 of 2.

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.