Class array init : Array : Collections Data Structure C# Source Code


Custom Search

C# Source Code » Collections Data Structure » Array »

 

Class array init








    

/*
Learning C# 
by Jesse Liberty

Publisher: O'Reilly 
ISBN: 0596003765
*/

 using System;

 namespace ArrayDemo
 {

     // a simple class to store in the array
     class Employee
     {
         private int empID;

         // constructor
         public Employee(int empID)
         {
             this.empID = empID;
         }
     }

     public class TesterArrayDemoInit
     {
         public void Run()
         {
             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);
             }

         }

         [STAThread]
         static void Main()
         {
             TesterArrayDemoInit t = new TesterArrayDemoInit();
             t.Run();
         }
     }
 }
           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Collections Data Structure
» Array