[Previous] [Contents] [Next]

Retrieving the Type of an Instance


The following example shows how to retrieve a Type object for an instantiated int: -

using System;
using System.Reflection;

class TypeObjectFromInstanceApp
{
    public static void Main(string[] args)
    {
        int i = 6;
        Type t = i.GetType();
        Console.WriteLine(t.Name);
    }
}

[Previous] [Contents] [Next]