コード例 #1
0
        public static void DisplayArray(ArrayInt a)
        {
            string message = "";
            int    j       = 1;

            Console.WriteLine("Your array has:");
            for (int i = 0; i <= a.GetSize(); i++, j++)
            {
                if (j % 5 == 0)
                {
                    j        = 0;
                    message += " " + a.GetAt(i).ToString() + System.Environment.NewLine;
                }
                else
                {
                    message += " " + a.GetAt(i).ToString() + " ";
                }
            }
            Console.Write(message + System.Environment.NewLine);
        }
コード例 #2
0
        public static void TestGetAt()
        {
            string test = "GetAt";

            Console.WriteLine("We will test GetAt. Which Index Would you like to see?");
            try
            {
                int input  = int.Parse(Console.ReadLine());
                int output = myArray.GetAt(input);
                Console.WriteLine("You selected index " + input + " which returned " + output);
                TestAgain(test);
            }
            catch
            {
                ErrorAsk(test);
            }
        }