ex-09-01

来自「Programming Csharp Source Code(代码) Prog」· 代码 · 共 51 行

TXT
51
字号
//Example 09-01: Working with an array

namespace Programming_CSharp
{
   using System;
  
   // a simple class to store in the array
   public class Employee
   {
      // a simple class to store in the array
      public Employee(int empID)
      {
         this.empID = empID;
      }
      public override  string ToString()
      {
         return empID.ToString();
      }
      private int empID;

      private int size;
   }
   public class Tester
   {
      static void Main()
      {
         int[] intArray;
         Employee[] empArray;
         intArray = new int[5];
         empArray = new Employee[3];

         // populate the array
         for (int i = 0;i<empArray.Length;i++)
         {
            empArray[i] = new Employee(i+5);
         }
           
         for (int i = 0;i<intArray.Length;i++)
         {
            Console.WriteLine(intArray[i].ToString());
         }

         for (int i = 0;i<empArray.Length;i++)
         {
            Console.WriteLine(empArray[i].ToString());
         }
      }
   }
}

⌨️ 快捷键说明

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