8. C #--one-dimensional arrays, two-dimensional arrays, jagged arrays

Source: Internet
Author: User

Using system;using system.collections.generic;using system.linq;using system.text;using  system.threading.tasks;namespace consoleapplication1{    class program{         static void main (String[] args) {             //declares a one-dimensional array and outputs              console.writeline ("Ouput  array.");             string []friendNames =  {"Robert", "Mike", "Jeremy"  };            int  i;            console.writeline ("here  Are {0} of my friends ",  friendnames.length);             for  (I = 0; i < friendnames.length;i++ ) {                 console.writeline (Friendnames[i]);}             console.writeline ("ouput double  array. ");             //declares a two-dimensional array and outputs              double[,] hillheight = { {1,2,3,4},{ 5,6,7,8}};            foreach  (double  Height in hillheight) {                 console.writeline ("{0}", height);}             console.writeline ("Ouput divisor  array. ");             //declares a jagged array, an array ofArray             //divisor1to10, which is used to protect the int[] element, not an int element;             //need to traverse the int[] element              int[][] divisor1To10 = {                                         new int []{1},                                        new int []{1,2},                                        new int []{1,3},                                        new int []{1,2,4 },                                        new int []{1,5},                                        new int []{1,2,3,6},                                        new int []{1,7},                                        new  int []{1,2,4,8},                                        new int []{1,3,9},                                        new int []{ 1,2,5,10}};            foreach  (int[]  Divisorofint in divisor1to10) {                foreach   (Int divisor in divisorofint) {                     console.writeline (divisor);}}             console.readline (); }}}


This article comes from the "Ricky's blog" blog, please be sure to keep this source http://57388.blog.51cto.com/47388/1650618

8. C #--one-dimensional arrays, two-dimensional arrays, jagged arrays

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.