program.cs

来自「csharp课本的源代码」· CS 代码 · 共 30 行

CS
30
字号
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace ForeachExample
{
    class Program
    {
        static void Main(string[] args)
        {
            //声明一个Hashtable集合hs,并使用Hashtable.Add方法为其添加带
            //有指定键和值的元素;
            Hashtable hs = new Hashtable();
            hs.Add("001", "str1");
            hs.Add("002", "str2");
            hs.Add("003", "str3");
            //循环显示hs集合的每个元素;
            Console.WriteLine("code       string");
            foreach (string s in hs.Keys)
            {
                Console.WriteLine(s + "          " + hs[s]);
            }
            //按回车键结束
            Console.ReadLine();

        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?