コード例 #1
0
ファイル: DemoSquares.cs プロジェクト: ZachOlivier/MyWork
        public static void Main()
        {
            Square[] squareArray = new Square[5];
            int x;
            for (x = 0; x < squareArray.Length; ++x)
                squareArray[x] = new Square();
            squareArray[1].Length = 2;
            squareArray[2].Length = 3;
            squareArray[3].Length = 4;
            squareArray[4].Length = 5;

            Console.WriteLine();
            Console.WriteLine("  The 1st square's length is {0}, which means the area is {1}", squareArray[0].length, squareArray[0].area);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("  The 2nd square's length is {0}, which means the area is {1}", squareArray[1].length, squareArray[1].area);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("  The 3rd square's length is {0}, which means the area is {1}", squareArray[2].length, squareArray[2].area);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("  The 4th square's length is {0}, which means the area is {1}", squareArray[3].length, squareArray[3].area);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("  The 5th square's length is {0}, which means the area is {1}", squareArray[4].length, squareArray[4].area);

            Console.ReadLine();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: RMiller28/Chapter7
        static void Main(string[] args)
        {
            Square[] SideA = new Square[10];

            for (int i = 0; i < SideA.Length; i++)
            {
                SideA[i] = new Square(i + 10);
                Console.WriteLine(SideA[i].Area);
            }
        }