. Net written test (2)

Source: Internet
Author: User

1. XML Web Service Principle: using SOAP (Simple Object Access Protocol) to call remote methods over http, you can also use WSDL (web Service Description Language) to complete the description of the web service, and then use UDDI to register the services provided by each service provider.

 

2..net Remoting Working principle: the server sends a process number and a program domain number to the client to determine the object location.

 

3. PDB is a file used to save debugging and project status information. The pdb file is generated during debugging. It should be placed in the same directory as the corresponding application Assembly during debugging.

 

4. 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 methods 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. Object consistency means that two objects are the same object, and the reference is the same. The same object means that the values of the two objects are equal, but the references are not necessarily the same.

A. Equals (B) indicates that a is consistent with B, and a = B indicates that a is equal to B.

 

6. Important webconfig nodes:

System. web system Configuration

Compilation dynamic debugging and compilation settings

CustomErrors custom error information settings

Authentication. This section sets the authentication policy for the application.

Authorization. This node sets the application authorization Policy.

 

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

 

8.Database Query Optimization

 1. polymorphism, compatibility with multiple databases;
2. Supports page turning, total number of queries, and page number display;
3. handling more than 1 million of the data volume;

Create procedure dbo. LSP_SP_SelectElementByPage @ SelectFields varchar (200),/* List of fields to be queried */@ Condition varchar (300),/* query Condition */@ PageSize int = 20, /* page size. The default value is 20 */@ PageNumber int = 1/* page number, the default value is the first page * // * @ PageCount int out. The total number of pages meeting the conditions is returned */AS begin declare @ count int select @ count = count (*) from lsp_t_elementInfo if (@ count % @ PageSize = 0) set @ count = @ count/@ PageSize else set @ count = @ count/@ PageSize + 1 select @ count PageCount select IDENTITY (int, 1, 1) as iid, ElementName, type into # temptable from LSP_T_ElementInfo select * from # temptable where iid between @ PageSize * (@ PageNumber-1) and @ PageSize * @ PageNumber end GO

 

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

using System.Text; StringBuilder sb = new StringBuilder(0, 10000); string strABC = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"; string[] ABC = strABC.Split(','); int len = ABC.Length; Random rd = new Random(); for (int i = 0; i < 10000; i++) {   sb.Append(ABC[rd.Next(len)]); }

 

10. generate an int array with a length of 100 and insert 1-100 randomly into it, 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[i]=(int)myList[i];

 

11. Write a selection Sorting Algorithm in C # And use your own programming style.

Private int min; public void xuanZhe (int [] list) // select the sort {for (int I = 0; I <list. length-1; I ++) {min = I; for (int j = I + 1; j <list. length; j ++) {if (list [j] <list [min]) min = j;} int t = list [min]; list [min] = list [I]; list [I] = t ;}}

 

12. Write a function to calculate the value of N: 1-2 + 3-4 + 5-6 + 7 ...... + N

public int returnSum(int n)     {         int sum = 0;         for (int i = 1; i <= n; i++)         {             int k = i;             if (i % 2 == 0)             {                 k = -k;             }             sum = sum + k;         }         return sum;     }

Method 2:

1-2 + 3-4 + 5-6 + 7 +... + n can be divided into two situations:  (1) When n is an even number, 1-2 + 3-4 + 5-6 + 7 +... + n = (1-2) + (3-4) + (5-6) + ...... + [(N-1)-n]                                   =-1×(n/2                                   =-n/2  (2) When n is an odd number, 1-2 + 3-4 + 5-6 + 7 +... + n = (1-2) + (3-4) + (5-6) + ...... + [(N-2)-(n-1)] + n                                     =-1×(n-1)/2 +n                                      =(n+1)/2 Therefore, the final algorithm is as follows:

public static int CalculateCrossNumberSequence(int index){  if (index <= 0)  {     return 0;  }     return index % 2 == 0 ? -index / 2 : (index + 1) / 2;
}

13. 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)

Solution 1: select top10 * from A where id not in (select top30 id from A) solution 2: select top10 * from A where id> (select Max (id) from (select top30 id from A) as)

 

14. Is there A table with tb columns A, B, and C? How to write an SQL statement to implement the following functions: If A> B is displayed, B> C is selected.

select case when a>b then a when b>c then b else c end as result from tb

 

15. What are the benefits of generics?

Generic: multiple data types can be operated on the same code by using parameterized types. The type is abstracted by using parameterized types to Achieve flexible reuse.

Benefits: type security, reduced binning, improved performance and quality, and reduced repetitive programming tasks

 

16. What is SQL injection?

1' or 1 = 1

 

       

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.