ch4_03.cs
来自「《c#技术内幕代码》」· CS 代码 · 共 38 行
CS
38 行
using System;
using System.Collections;
class CH4_3
{
public static void Main()
{
// First, an array of integers
int[] arrayOfInt = { 1, 2,3, 4, 5 };
foreach ( int i in arrayOfInt )
{
Console.WriteLine("Int {0}", i );
}
// Now, how about an array of strings?
string[] arrayOfStr = { "Hello", "Goodbye", "Why me?" };
foreach ( string s in arrayOfStr )
{
Console.WriteLine("String {0}", s );
}
// Finally, let's look at a dictionary collection
Dictionary d = new Dictionary(10);
d.Add( 100, "Science");
d.Add( 200, "Math");
d.Add( 300, "English");
d.Add( 400, "History");
d.Add( 500, "Gym");
foreach ( DictionaryEntry de in d )
{
Console.WriteLine( "Entry Key {0} Value {1}", de.Key, de.Value );
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?