How to Create Array Of Objects and show the Type of Value

  1. using System.IO;  
  2. using System;  
  3. class arrayOfObjects  
  4. {  
  5.     public static void Main(string[] args)  
  6.     {  
  7.         object[] arrayOfObjects = new object[5];  
  8.         arrayOfObjects[0] = 1000;  
  9.         arrayOfObjects[1] = 10.00;  
  10.         arrayOfObjects[2] = true;  
  11.         arrayOfObjects[3] = new DateTime(2013, 12, 12);  
  12.         arrayOfObjects[4] = "This is string object";  
  13.         foreach(object obj in arrayOfObjects)  
  14.         {  
  15.             Console.WriteLine("Type: {0}, Value: {1}", obj.GetType(), obj);  
  16.         }  
  17.     }  
  18. }  
Output:

Type: System.String, Value: 1000
Type: System.String, Value: 10.00
Type: System.String, Value: true
Type: System.DateTime, Value: 12/12/2013 00:00:00
Type: System.String, Value: This is string object