. NET Foundation Review A

Source: Internet
Author: User

1.int[] Arrint =New int[5]; the left side of the equal sign opens up a small stack of space, the equals sign opens up 5 spaces to the right of the heap, and the first space opened in the heap is assigned to the space in the stack.string[,] productlist =New string[2,5]; productlist[0,0] ="number 1th"; productlist[1,0] ="88 USD"; productlist[0,1] ="Number 2nd"; productlist[1,1] ="99 USD"iterate over an array if it is a 1-dimensional array for(intI=0; i<productlist.length;i++{} If you traverse a 2-D arrayStatic voidMain (string[] srts) {Doublemymoney="30000"; Buystuff ("Apple", out DoubleMymoney); }Static DoubleBuystuff (stringProname, out DoubleMoney ) { for(intI=0; I<productlist.getlength (0); i++){  if(productlist[0, I] = =proname) {    DoubleProprice = convert.todouble (productlist[1, I]); return(money-proprice);}} This place is designed to return a value of 2 one is a commodity one is the rest of the moneyref: Referencing a parameter out: Output parameters must be copied before using the Out parameter: Before you use it in a method, you must assign a value.   You must assign a value before returning it in a method. Doublemymoney="30000"; Buystuff ("Apple",ref DoubleMymoney); Static stringBuystuff (stringProname,DoubleMoney ) { Money= Money-"Spend the money"; //To the right of the equal sign, first to find the reference value in the stack through money, and then take the value of the application to lose the value of the flower//The result is returned to ref's Mymoney;}             refAnd outThe difference is the same: generally use out/A ref-decorated parameter that is passed a reference.  Different points: Out key is focused on the output parameters, that is, I call your method, is to get the value by the way of output parameters (return value is also to get the value by means): Usually when the method needs to return multiple values.  This is usually used when the method needs to return multiple values.    All, out parameters must be assigned before the method returns (before the end).   Ref focuses on modification, that is, I call you this method, and the purpose of passing in the parameter is to modify the incoming variable in the method again.  Therefore, the ref parameter must be assigned before it is passed in. 2. Method (function): Reusing static methods [Static] Console.ReadLine () can be called by the class name; Public Static classconsole{} Console static class, Console.WriteLine (this kind has 19 methods) can fully show the method overloaded method name the same method parameter type and number of different;3.returnReturns a value for the method, and a colleague can exit the program immediately. BreakExits the current loop,Continueexit this cycle. 4.voidNo type no return value; method to accept the return value: the type of the accepted variable must be the same as the return value. 5Stack and heap feature stacks: Stack space is small, but the speed of access is fast heap: heap space is large, but the speed of access is slow NEW keyword:1Open a space in the heap;2. Create an Object3. Call the constructor6.paramsvariable parameter features:1can be directly passed into the array, you can also directly pass the same type of parameter array with the elements in2. variadic parameters in the parameter list of a method can only have one variable parameter in a method's parameter list this only one variable parameter must be at the end of the argument list

. NET Foundation Review A

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.