-------
Windows Phone 7手机开发、
.Net培训、期待与您交流! -------
今天看了看数组中的元素如何读取,发现这两种应该是比较常用的了。
static void Main(string[] args)
{
//定义数组,数组中有三个元素;
string[] friendName = { "暴漫", "nice", "lala" };
//定义变量i;
int i;
Console.WriteLine("这个数组里面有{0}个元素", friendName.Length);
//for循环,以此i+1,输出数组中的元素;
//for (i = 0; i < friendName.Length; i++)
//{
// Console.WriteLine(friendName[i]);
//}
//Console.ReadKey();
//应用foreach,遍历数组。
foreach (string friendname in friendName)
{
Console.WriteLine(friendname);
}
Console.ReadKey();
}