. Net interview questions

Source: Internet
Author: User

Q1: Maintain database integrity and consistency. Do you like to use triggers or write business logic? Why?
A: Use constraints (including check, primary key, unique key, foreign key, and non-empty fields) as much as possible. This approach is most efficient. Use triggers, this method ensures that no matter which business system accesses the database, the database integrity and consistency can be maintained. Finally, the self-writing business logic can be used for implementation. However, this method is the least efficient and the most complex in programming, this is the next strategy.

Q2: ADO. What are the main improvements to net over ado?
A: In my opinion, compared with ADO, ADO. NET provides data set and data adapter, which facilitates distributed processing and reduces resource consumption on database servers.

Q3: Asp. Net compared with ASP, what are the main advances?
A: Asp. net is more advanced than ASP, and some are: object-oriented programming and pre-compiled server-side code are implemented in form; better security mechanism (the background code of the aspx files runs with another account, which is different from the account used to start IIS.

Q4: What is the delegate in C? Is an event a delegate?
A: delegate is essentially a "method interface", which is equivalent to a function pointer in C/C ++. Of course, delegate is safer than function pointer and is usually used for event processing in C. Compared with Java, you can avoid using a large number of small-granularity anonymous classes.

The event is not a delegate, but the nature of the event determines the parameters that can be accessed by the program logic that processes it. Therefore, the event processing logic in C # is encapsulated as delegate (a "method interface "). In fact, if you are dealing with custom events, it is also possible to use interfaces as in Java, but doing so in C # is generally not particularly beneficial.

Q5. create an application that displays the employee list of the company. You can use a DataGrid Control to display the employee list. You want to modify this control to display the total number of employees in the footer of the grid. What should you do? (C? )

A. Override the onprerender event. When the footer row of the grid is created, the total count is displayed.
B. Override the onitemcreated event. When the footer row of the grid is created, the count is displayed.
C. Override the onitemdatabound event. When the footer row of the grid is created, the count is displayed.
D. Override the onlayout event. When the footer row of the grid is created, the total count is displayed.

Q6. you want to create an ASP. NET application to run the web site within allwin. The application contains 50 pages. You want to configure this application so that when an HTTP code error occurs, it can display a custom error page to the user. What do you do if you want to accomplish these goals at the minimum cost? (Multiple choice) (cd)
A. Create an application_error process in the global. asax file of the application to handle ASP. NET code errors.
B. Create an applicationerror section in the web. config file of the application to handle ASP. NET code errors.
C. Create a customerrors event in the global. asax file of the application to handle HTTP errors.
D. Create a mermerrors section in the web. config file of the application to handle HTTP errors.
E. Add a page indicator on each page of the application to handle ASP. NET code errors.
F. Add a page indicator to each page of the application to handle ASP. net http errors.

Q7. your company has a DB server named allwin installed with Ms sqlserver 2000. Now you need to write a database connection string to connect to a test database named pubbase instance in SQL Server on allwin. Which of the following strings should be selected? (B)
A. "Server = allwin; Data Source = pubbase; initial catalog = test; Integrated Security = sspi"
B. "Server = allwin; Data Source = pubbase; database = test; Integrated Security = sspi"
C. "Data Source = allwin \ pubbase; initial Category = pubbase; Integrated Security = sspi"
D. "Data Source = allwin \ pubbase; database = test; Integrated Security = sspi"

Q8. you have created an ASP. NET application for allwin. This application calls an XML Web Service. This XML Web Service returns a DataSet object that contains the company employee list. How do you use this XML Web Service in this program? (? )
A. Select system. Web. Services. dll from the. NET tag in the reference dialog box.
B. Enter the XML Web Service address in the "Web reference" dialog box.
C. Add a using statement to your global. asax. CS and specify the XML Web Service address.
D. Write an event processor in your global. asax. CS to import the corresponding. WSDL and. Disco files of this XML Web Service.

Q9. create an ASP. NET application to display a sorted list in the DataGrid Control. Product data is stored in a Microsoft SQL Server database named pubbase. The primary key of each product is productid, numeric, and each product has a letter Description field named productname. You use a sqldataadapter object and a sqlcommand object to obtain product data from the database by calling a stored procedure. You can set the commandtype attribute of the sqlcommand object to commandtype. storedprocedure, and set its commandtext attribute to procproductlist. You have obtained a datatable object, which is a list of products that have been sorted in descending order by productid. You want to display productname in reverse alphabetical order. What should you do? (B)
A. Modify the commandtype attribute of the sqlcommand object to commandtype. Text and select * From procproductlist order by productname DESC ". Then bind the datatable object to the DataGrid Control.
B. Create a New dataview based on this able object and set the sort attribute of this dataview to "productname DESC ". Then bind the dataview object to the DataGrid Control.
C. Set the allowsorting attribute of the DataGrid Control to true, and set the sortexpression attribute of the datagridcolumn to "productname DESC" to display productname. Then bind the datatable object to the DataGrid Control.
D. Set the displayexpression attribute of the able object to "order by productname DESC ".. Then bind the datatable object to the DataGrid Control.

Q10.c # code implementation to ensure that Windows programs only have one instance)
///

/// Main entry point of the application.
///

[Stathread]
Staticvoid main ()
{
// Prevent the program from running for multiple times
If (! Oneinstance. isfirst ("getpayinfo "))
{
MessageBox. Show ("Warning: The program is running! Do not open the program again! You can find it in the system bar in the lower right corner! "," Program error prompt: ", messageboxbuttons. OK, messageboxicon. Stop );
Return;
}
Application. Run (New form1 ());
}
// ******************** Prevent multiple program executions ************** ************
Publicpolicactclass oneinstance
{
///

/// Determine whether the program is running
///

////// If the program is run for the first time, true is returned; otherwise, false is returned.
Publicstaticbool isfirst (string appid)
{
Bool ret = false;
If (openmutex (0x1f0001, 0, appid) = intptr. Zero)
{
Createmutex (intptr. Zero, 0, appid );
Ret = true;
}
Return ret;
}
[Dllimport ("kernel32.dll", charset = charset. Auto)]
Privatestaticextern intptr openmutex (
Uint dwdesiredaccess, // access
Int binherithandle, // inheritance Option
String lpname // Object Name
);

[Dllimport ("kernel32.dll", charset = charset. Auto)]
Privatestaticextern intptr createmutex (
Intptr lpmutexattributes, // SD
Int binitialowner, // initial owner
String lpname // Object Name
);
}
The article you are reading is collected from the Internet by www.teaku8.com.

Q11. brief the access permissions of private, protected, public, and internal modifiers.
PRIVATE: a private member that can be accessed within the class. Protected: protects members, which can be accessed within the class and in the inheritance class. Public: A Public member. It is completely public and has no access restrictions. Internal: accessible within the same namespace.

Q12. write an SQL statement: extract the 31st to 40th records in Table A (sqlserver, with an automatically increasing ID as the primary key. Note: The ID may not be consecutive .)
Select top 10 * from a where id not in (select top 30 ID from)
Solution 2: Select top 10 * from a where ID> (select max (ID) from (select top 30 ID from a) as)

Q13. list several methods for passing values between ASP. NET pages.
1. Use querystring, such ....? Id = 1; response. Redirect ()....
2. Use session Variables
3. Use server. Transfer
2. Describes several common methods for passing parameters between pages in. NET and their advantages and disadvantages.
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.

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

Q15. What is the error handling mechanism of. Net?
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.

Similarities and differences between interfaces and classes in q16 and 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.

Q17. Similarities and 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...

Q18. what are the meanings of using and new keywords in C?
Using introduces a namespace, or automatically calls its idespose after an object is used. New instantiates an object, or modifies a method. This method is completely rewritten.

Q19. 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? X = 1, y = 0

Q20. 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 );
}
The article you are reading is collected from the Internet by www.teaku8.com.

}
What is the output result? X = 1, y = 2

Q21. what are the differences between classes and structures?
One of the biggest differences is the reference type, and the other is the default value type.

Q22. 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 ).
This (C #) Me (VB.net ).

Q23. how to customize messages in. Net (C # Or VB.net) and process these messages in the form.
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;
}
}

Q24. how to start another program in. Net (C # Or VB.net.
Process

Q25. how to cancel closing a form in. Net (C # Or VB.net)
Private void form1_closing (Object sender, system. componentmodel. canceleventargs E)
{
E. Cancel = true;
}

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

Q27. there is a double type 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 );

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.