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



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

using System.IO;  
using System;  
class arrayOfObjects  
{  
    public static void Main(string[] args)  
    {  
        object[] arrayOfObjects = new object[5];  
        arrayOfObjects[0] = 1000;  
        arrayOfObjects[1] = 10.00;  
        arrayOfObjects[2] = true;  
        arrayOfObjects[3] = new DateTime(2013, 12, 12);  
        arrayOfObjects[4] = "This is string object";  
        foreach(object obj in arrayOfObjects)  
        {  
            Console.WriteLine("Type: {0}, Value: {1}", obj.GetType(), obj);  
        }  
    }  
} 

0 Comment's

Comment Form

Submit Comment