using System; using System.Collections; namespace huangyibiao { class Program { public static void PrintValues(IEnumerable ie, char chrSeperator) { foreach (Object obj in ie) { Console.Write("{0}{1}", chrSeperator, obj); } Console.WriteLine(); } static void Main(string[] args) { Stack myStack = new Stack(); myStack.Push("黄仪标"); myStack.Push("何崇"); myStack.Push("王博"); myStack.Push("何江"); PrintValues(myStack, '\t'); Console.WriteLine("\tPop : " + myStack.Pop()); Console.WriteLine("\tPeek: " + myStack.Peek()); PrintValues(myStack, '\t'); Console.WriteLine("\tPop : " + myStack.Pop()); Console.WriteLine("\tPeek: " + myStack.Peek()); PrintValues(myStack, '\t'); Console.WriteLine("\tPop : " + myStack.Pop()); Console.WriteLine("\tPeek: " + myStack.Peek()); PrintValues(myStack, '\t'); Console.WriteLine("\tPop : " + myStack.Pop()); PrintValues(myStack, '\t'); } } }
using System;namespace huangyibiao{ class Program { static void Main(string[] args) { //一维数组 int[] iArrNumber = new int[5]; Console.WriteLine("Length: " + iArrNumber.Length); //二维数组 string[,] strNames = new string[5,4]; Console.WriteLine("Length: " + strNames.Length); //交错数组 int[][] iArrElements = new int[5][]; for (int i = 0; i < iArrElements.Length; i++) { iArrElements[i] = new int[i + 1]; } for (int i = 0; i < iArrElements.Length; i++) Console.WriteLine("Length: " + iArrElements[i].Length); } }}
using System;namespace huangyibiao{ class Program { static void Main(string[] args) { Console.Write("请输入要录入的学生人数: "); int iCounter = 0; iCounter = Int32.Parse(Console.ReadLine()); string[] strNames = new string[iCounter]; for (int i = 0; i < iCounter; i++) { Console.Write("请输入第{0}个学生的姓名: ", i + 1); strNames[i] = Console.ReadLine(); } Console.WriteLine("您已经登记的学生的姓名如下:"); foreach (var name in strNames) { Console.WriteLine(name); } } }}