黑马程序员技术交流社区

标题: C#编程--数组,foreach遍历数组,字符串组 [打印本页]

作者: 生活墨墨    时间: 2012-12-4 16:36
标题: C#编程--数组,foreach遍历数组,字符串组
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
    class testArray
    {
        static void Main(string[] ager)
        {
            string[] Strs = {"A","B","1","2"};
            int[] ints = {2,3,6};
            //循环遍历字符串组
            for (int i = 0; i < Strs.Length; i++)
            {
                Console.WriteLine(Strs[i]);
            }
            foreach (string str in Strs)
            {
                Console.WriteLine(str);
            }
            //数组
            foreach (int i in ints)
            {
                Console.WriteLine(i.ToString());
            }
            Console.ReadLine();
        }
    }
}


作者: 许庭洲    时间: 2012-12-8 07:32
值得学习ing!




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2