foreach的使用

时间:2021-09-17 14:34:15   收藏:0   阅读:34

直接访问数组每一个数

 1 using System;
 2 namespace ArrayApplication
 3 {
 4     class MyArray
 5     {
 6         static void Main(string[] args)
 7         {
 8             int[] n = new int[10];
 9             int i;
10             for(i=0;i<10;i++)
11             {
12                 n[i] = i + 100;
13             }
14             foreach(int j in n)
15             {
16                
17                 Console.WriteLine("{0}",  j);
18 
19             }
20             Console.ReadKey();
21 
22             
23         }
24     }
25 }

 

原文:https://www.cnblogs.com/welasss/p/15302875.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!