标签:c#
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)
{
//声明一维数组,并输出
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.");
//声明二维数组,并输出
double[,] hillheight = { {1,2,3,4},{5,6,7,8}};
foreach (double height in hillheight)
{
Console.WriteLine("{0}",height);
}
Console.WriteLine("ouput divisor array.");
//声明锯齿数组,数组的数组
//divisor1To10,用于保护int[]元素,而不是int元素;
//需要对int[]元素进行遍历
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();
}
}
}本文出自 “Ricky's Blog” 博客,请务必保留此出处http://57388.blog.51cto.com/47388/1650618
标签:c#
原文地址:http://57388.blog.51cto.com/47388/1650618