. A c # questionnaire! Access Permissions for private, protected, public, and internal Modifiers

Source: Internet
Author: User
Tags sql server driver odbc sql server driver
3. Briefly describe 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.
4. Write an SQL statement: extract the 31st to 40th records in Table A (sqlserver, using the 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)
5. 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.
2. Differences between override and overload
Override is used to override the method of the parent class. The method or operator with the same name has different types of parameters.
3. 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.
4. Similarities and Differences between interfaces and classes in C #
Interfaces and classes are classes. Different things, interfaces only contain methods or attribute declarations, and do not contain specific implementation methods. Code The interface can implement multiple inheritance, while the class can only be a 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.
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...
1.
In C #, what are the meanings of using and new keywords?
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.
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? X = 1, y = 0
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? X = 1, y = 2
4. 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.
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 ).
This (C #) Me (VB.net ).
2. 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;
}
}
3. How to start another one in. Net (C # Or VB.net) Program . Process
4. 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;
}
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.
There are several usage methods for new
First: New Class ();
Method 2: Overwrite
Public new xxxx (){}
Third: the new constraint specifies that any type parameter in the generic class declaration must have a common non-parameter constructor.
2. How to copy an array to the arraylist
Foreach (Object o in array) arraylist. Add (O );
3. What data sources can the DataGrid. datasouse connect to? [dataset, datatable, dataview]
Dataset, datatable, dataview, ilist
4. Overview of reflection and serialization
Reflection: The Assembly contains modules, while the module contains types and types, including Members. Reflection provides encapsulated assembly, module, and type objects. You can use reflection to dynamically create instances of the type, bind the type to an existing object, or obtain the type from an existing object. Then, you can call a method of the type or access its fields and attributes.
Serialization: serialization is the process of converting an object into a format that is easy to transmit. For example, you can serialize an object and Use http to transmit the object between the client and the server over the Internet. At the other end, deserialization reconstructs the object from the stream.
5. Overview of O/R Mapping principles
Use reflection to configure database table ing
7. What are the characteristics of classes modified with sealed?
The sealed modifier is used to prevent other classes from being derived from the modified class. If a sealed class is specified as the base class of other classes, a compile-time error occurs.
The sealed class cannot be an abstract class at the same time.
The sealed modifier is mainly used to prevent unintentional derivation, but it can also promote some runtime optimization. Specifically, because the sealed class will never have any derived class, the call to the virtual function Member of the sealed class instance can be converted to a non-virtual call for processing.
11. detail the similarities and differences between class and struct in. net!
Class: put in? Put struct in?
Struct value transfer
Classes have many similarities with structures: structures can implement interfaces and have the same member types as classes. However, the structure is different from the class in several important aspects: the structure is a value type rather than a reference type, and the structure does not support inheritance. The schema values are stored on the stack or inline ". Careful programmers can sometimes use structures intelligently to enhance performance.
12. Overview of remoting and WebService in. NET and its practical application.
Remote logical call. The remoing interface can only be used in. net.
13. What is code-behind technology aspx and CS?
14. Overview of the three-tier architecture Web/Business/dataaccess
15.asp.net: How to Implement the MVC mode, for example! Web/Business/dataaccess
2. What is a user control in Asp.net?
A: The user control is. the ascx extension can be dragged to different pages for calling to save code. for example, login may be available on multiple pages and can be used as a user control, however, one problem is that the relative paths of the images in the directories after the user control is dragged to different levels will become inaccurate, and you need to adjust them by writing your own methods.
3. What is an application domain? What is regulated code? What is a strong system? What is packing and unpacking? What is overload? What are the explanations of CTS, CLS, and CLR?
A: boxing refers to converting the value type to the reference type. From the perspective of Ms Il, it looks like boxing. If you remember correctly, the value is transferred from the stack to the heap. on the contrary, a method with the same name and number of parameters can return the same method. when the CLR is running in a common language, the rest is unclear.
4. List the XML technologies you know and their applications.
A: XML is a good thing. It is used for saving configurations and communication between sites.
5. What is the difference between the value type and the reference type? Write the sample code of C.
A: The structure is the value type, and the class is the reference type. Therefore, the data transfer structure is the application of the value type, and the data transfer object or class is the reference type. Do not write more.
6.ado.net what are common objects? Describe them separately.
A: Connection command sqladapter dataset datatable dataview and so on. The data cannot be written.
7. How to understand delegation?
A: It is said to be equivalent to a function pointer. If a delegate is defined, the method can be called without calling the original method name.
Msdn2005 explains this as follows:
Delegation has the following features:
The delegate is similar to a C ++ function pointer, but it is type-safe.
The delegate allows passing methods as parameters.
A delegate can be used to define a callback method.
The delegate can be linked together. For example, multiple methods can be called for an event.
The method does not need to be exactly matched with the delegate signature. For more information, see covariant and inverter.
C #2.0 introduces the concept of anonymous methods, which allow passing code blocks as parameters instead of Individually Defined methods.
What are the similarities and differences between interfaces and classes in C.
A: interfaces are responsible for defining functions. In projects, interfaces are used to define the concepts of classes, Operation classes, and abstract classes!
The class is responsible for the specific implementation of the function!
There are also abstract class definitions in the class. The difference between the abstract class and the interface is:
An abstract class is an incomplete class. The class contains abstract methods, attributes, and specific methods and attributes, which requires further specialization.
But the interface is a behavior specification, and everything in it is abstract!
A class can only inherit one base class, that is, the parent class, but multiple interfaces can be implemented.
9 .. What classes are used to read and write databases in. Net? Their role
A: You can write this class yourself. Do you mean a base class? Configuration, sqlconnection, and sqlcommand are all used.
10. Similarities and Differences between UDP and TCP connections.
A: the former is only transmitted, no matter the data cannot be reached, no connection is required. The latter ensures that the transmitted data is accurate and must be linked.
11.asp.net identity authentication methods? What are their principles?
A: The principles of form authentication and Windows Integration authentication are unclear.
13. What is code-behind technology.
A: code separation is wise. It is uncomfortable to mix it into a pile like ASP. you can also understand that the HTML code is written at the front end, and the C # code is written at the back end. of course, there are also scripts and class calls at the front end, which can also be written together.
In 15..net, what namespaces do classes that read and write XML belong?
A: system. xml
16. Explain the significance and functions of UDDI and WSDL.
A:
17. What is soap and what applications are there.
A: Simple Object Access Protocol (SOAP) is a protocol used to exchange information and execute remote process calls in a distributed or distributed environment. It is an XML-based protocol. When using soap, you do not need to consider any specific transmission protocol (the most commonly used HTTP protocol). You can allow any type of objects or code to communicate with each other in any language on any platform. This type of communication uses the XML format of the message, see: http://playist.blogchina.com/2521621.html
20. What are common WebService call methods?
A:
Web services can be accessed using a HTTP-GET HTTP-POST from a browser, ASP page, or other Web service calls, or from an ASP page or other Web Service, SOAP requests to other web services HTTP-GET HTTP-POST soap uses Web Services proxy
6. What is the difference between private assembly and shared assembly?
A private assembly is usually used by a single application and stored in the directory where the application is located, or in a subdirectory under this directory. Shared assembly is usually stored in the Global Assembly Cache, which is an assembly repository maintained by. Net runtime. Shared assembly is usually a code library that is useful to many applications, such as. NET Framework classes.
7. What is the difference between a process and a thread? What is the difference between a process and a program?
Generally, an application corresponds to one or more processes, which can be seen as the identity of the application in the * system. A process usually consists of multiple threads, the thread is the minimum unit for * the system to allocate processing time for the application.
8. What are the meanings of Clr and IL?
CLR: when running in the public language, it is similar to the JVM and Java Virtual Machine in Java. In the. NET environment, various Programming Language Using a common basic resource environment, which is the CLR, the CLR will directly communicate with the * system, and the programming language such as C #. net will try to avoid direct communication with * as a system and enhance the execution security of program code. You can see that CLR is a specific programming language such as C #. net and *. It also provides many resources for specific programming languages:
Il, intermediate language, also known as msil, Microsoft intermediate language, or cel, General intermediate language; all. net Source code (Written in any language) is compiled into il during compilation. The machine code is interpreted and executed by the just-in-time (JIT) compiler when the application is running.
10. Please explain ASP. . Net
Aps.net has five controls: non-empty verification, comparison verification, value range verification, regular expression verification, and custom verification. In addition, it also has a centralized information processing control.
11. Web controls can trigger server events. How does a server event occur and how it works? What is automatic transmission? Why use automatic transmission.
When a web control event occurs, the client submits the data back to the server. The server first calls the page_load event, then, server events are automatically called Based on the returned status information. When we click the client control, data is directly transmitted back to the service end in the form of a submission form.
The server event mechanism can be realized only through automatic return. If there is no automatic return mechanism, only client events can be called, but server events cannot be called.
12. Can the Web Control and HTML Server Control call the client method? If yes, how can I call it?
Yes
For example: <asp: textbox id = "textbox1" font-size: 9pt; color: Black "> clientfunction ();" runat = "server">
</ASP: textbox>
<Input id = "button2" value = "button" name = "button2"
Runat = "server" font-size: 9pt; color: Black "> clientfunction ();">
13. Please explain the important nodes in the web. config file
Appsettings includes custom application settings.
System. Web System Configuration
Compilation dynamic debugging and compilation settings
Customerrors custom error information settings
Authentication authentication. This section sets the authentication policy for the application.
Authorization authorization. This section sets the application Authorization Policy.
14. Please explain ASP. What is the relationship between web pages and hidden classes in. Net?
An ASP. NET page generally corresponds to a hidden class. Generally, a hidden class is specified in the ASP. NET page declaration. For example, the declaration of a page tst1.aspx is as follows:
<% @ Page Language = "C #" codebehind = "tst1.aspx. cs" autoeventwireup = "false" inherits = "t1.tst1" %>
Codebehind = "tst1.aspx. cs" indicates which code file is used when the page is compiled
Inherits = "t1.tst1" indicates the hidden class used when the table is running.
15. What is viewstate? Can it be disabled? Can all controls be disabled?
Viewstate is a mechanism for saving the state. You can disable the enableviewstate attribute when it is set to false.
16. What is the possible cause when I find that I cannot read the input data on the page? Solution
It is likely that the ispostback attribute of the page is not judged during data processing in page_load.
17. Please explain what is a context object and under what circumstances it should be used
Context object refers to the current attribute of the httpcontext class. This object is used when we want to access built-in objects (response, request, session, server, appliction, etc.) in a common class.
18. What is the difference between forwarding and redirection?
Forwarding means that the server jumps to page A and submits data to page B. Page B is processed and the server jumps to other pages.
Jump refers to the client jump
1. Briefly describe the detailed steps for synchronous communication programming using Socket
1. Use protocol and network address in applications and remote devices to initialize sockets
2. Create a listener by specifying the port and address in the Application
3. remote devices send connection requests
4. Applications accept connections to generate scoket communications
5. Communication starts between applications and remote devices (in communications, applications will be suspended until communication ends)
6. After the communication ends, close the socket of the application and remote device to recycle resources.
1. in C #, use text or images to describe the differences between string STR = NULL and string STR =.
String STR = NULL indicates that no memory space is allocated to him, while string STR = "" assigns it a memory space with a length of null characters.
2. Describe the similarities and differences between classes and struct in DOTNET: (10 points)
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.
}
}
}
}
____________________________________________________________________
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 = I still do not know, 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)
Select top ID from Table1 order by lastupdatedata DESC
8. Briefly discuss your understanding of the remoting and WebService technologies under the Microsoft. NET architecture and their practical applications. (10)
Remoting is. net is used to call methods across machine, process, and appdomain. For a three-structure program, remoting technology can be used to construct the program. it is the basic technology for distributed applications. similar to the previous DCOM web service, it is a common model for building applications and can be implemented on all operating systems that support Internet communication. Web service enables the combination of component-based development and web to achieve the best, component-based object model
9. What is SQL injection and how to prevent it? For example.
Attackers can exploit SQL keywords to attack websites. Filter keywords, etc.
The so-called SQL injection is a feature that uses the programmer's lax or non-detection of the legality of user input data and deliberately submits special code from the client, collect information about programs and servers to obtain desired information.
Http: // localhost/lawjia/show. asp? Id = 444 And user> 0. At this time, the server runs a query such as select * from table name where field = 444 and user> 0. Of course, this statement cannot run and must have an error, the error message is as follows:
· Error Type:
Microsoft ole db provider for ODBC drivers (0x80040e07)
A syntax error occurs when [Microsoft] [odbc SQL Server Driver] [SQL Server] converts the nvarchar value 'sonybb' to a column whose data type is int.
A generates an int array with a length of 100 and inserts 1-100 randomly into the array, which cannot be repeated.
Int [] intarr = new int [100];
Arraylist mylist = new arraylist ();
Random RND = new random ();
While (mylist. Count <100)
{
Int num = RND. Next (1,101 );
If (! Mylist. Contains (Num ))
Mylist. Add (Num );
}
For (INT I = 0; I <100; I ++)
Intarr = (INT) mylist;
20. Describe the differences between classes and structures.
1) The structure is a value type;
2) structure does not support inheritance;
3) The structure cannot define the default constructor;
4) The structure cannot define the destructor;
5) The structure cannot use the initial value to set the Domain value.

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.