.Net foundation face questions

To summarize the basics of interview questions .Net encountered here do the next record

1, try {} catch {} finally {} execution sequence

Whether try and catch block is whether there return, finally block always executes,

Try if no abnormality, the sequence of try → finally, if there is an abnormality in the try, the order is try → catch → finally.

If there is return, there are two different situations:

private int test1() {
        int i = 1;
        try {
            i++;
            Console.WriteLine("try:" + i);
            return i;
        } catch (Exception e) {
            i++;
            Console.WriteLine("catch:" + i);
        } finally {
            i++;
            Console.WriteLine("finally:" + i);
        }
        return i;
    }  

Output:

try:2
finally:3
2

Note: Because when information with a try in return, will first execute code before the return, then temporarily store information required return, and then execute code in the finally, finally saved by the return before return. Therefore, this method returns the value 3 after 2, rather than try finally calculated after the calculation.

 1 private List<Int32> test2() {
 2         List<Integer> list = new ArrayList<>();
 3         try {
 4             list.add(1);
 5             Console.WriteLine("try:" + list);
 6             return list;
 7         } catch (Exception e) {
 8             list.add(2);
 9             Console.Writeline("catch:" + list);
10         } finally {
11             list.add(3);
12             Console.Writeline("finally:" + list);
13         }
14         return list;
15     }

Output:

try:[1]
finally:[1, 3]
[1, 3]

Note: This is an example on how different it and, in fact, the problem is the parameter type, on a basic example of using a type, reference type used here. list is not stored in the variable itself, but the address of a variable, so when finally changed by the variable address, or will affect the method returns a value.

2, web Service understanding

That web service web services, for example to explain explain web services.

For example, a server on a Windows Server C # .Net applications developed A, there is a Java language development application B on Linux, B calls A application to application, or call each other, see each other for business data.

The client and server to be able to freely communicate with HTTP through Web Service, regardless of what the two procedures platforms and programming languages ​​Yes.

WebService remote call is a cross-technology and cross-platform language.

XML + XSD, SOAP and WSDL is composed of three WebService technology platform.

WebService HTTP protocol to transmit data, the data package in XML format

= HTTP protocol SOAP protocol + XML data format

WebService business end first through a WSDL file to illustrate your own home so what services can begin to call, what is the service (which methods the service there, what method accepts parameters are, what is the return value), the network address of the service with which url address indicated by what means the service is invoked.

3, the difference between the MVC and webAPI

 

4, XML understanding

 

Guess you like

Origin www.cnblogs.com/MirZhai/p/11925335.html