C# 打印和for循环的使用

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)
        {
            int[] numbers = new int[] { 1, 2, 3, 4, 5, 6, 7 };  // 定义不定长数组
            //Length表示获取长度
            for(int i = 0; i < numbers.Length; i++)
            {
                // writeLine:表示打印一行;Write:表示不换行打印
                Console.WriteLine(numbers[i]);  // 打印数组的内容
            }
            // ReadLine:读取一行,回车结束,返回字符串类型数据;Read:读取一个字符,回车结束,返回int行数据,貌似是ASCII码值
            Console.ReadKey();  // 等待任意字符
        }
    }
}

猜你喜欢

转载自www.cnblogs.com/namejr/p/10259364.html