. NET Learning notes----2015-06-24 (ArrayList collection Exercise)

Source: Internet
Author: User

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Collections;namespace_18 Collection of exercises {classProgram {Static voidMain (string[] args) {            #regionCreate a collection that adds numbers, averages and values, and a maximum and minimum value//ArrayList list = new ArrayList (); //list.            AddRange (New int[] {1, 2, 3, 4, 5}); //int sum = 0; //int max = (int) list[0]; //int min = (int) list[0]; //for (int i = 0; i < list. Count; i++)//{            //if ((int) list[i] > Max)//    {            //max = (int) list[i]; //    }            //sum + = (int) list[i]; //}            //Console.WriteLine ("The sum of the numbers in this set is {0}, the average is {1}, the maximum value is {2}", Sum, sum/list.)            Count, Max); //Console.readkey ();            #endregion            #regionWrite a set of length 10, which requires that 10 numbers (0-9) be stored randomly, requiring all numbers not to be duplicatedArrayList List=NewArrayList (); Random R=NewRandom ();  for(inti =0; I <Ten; i++)            {                intRnumber = R.next (0, -); //indicates that there is no random number in the collection                if(!list. Contains (Rnumber)) {list.                ADD (Rnumber); }                Else//indicates that there is no random number in the collection                {                    //once a repeating random number is generated, this cycle does not count, so i--i--; }            }             for(inti =0; I < list. Count; i++) {Console.WriteLine (list[i]);            } console.readkey (); #endregion        }    }}

ArrayList collection is not commonly used at present, because although it is convenient to store data, it is too cumbersome to extract.

. NET Learning notes----2015-06-24 (ArrayList collection Exercise)

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.