C# Type IsClass
Description
Type IsClass
gets a value indicating whether the Type
is a class; that is, not a value type or interface.
Syntax
Type.IsClass
has the following syntax.
public bool IsClass { get; }
Example
The following example creates an instance of a type and indicates whether the type is a class.
// www . j ava2 s . c o m
using System;
using System.Reflection;
public class MyDemoClass
{
}
public class MyTypeClass
{
public static void Main(string[] args)
{
try
{
Type myType = typeof(MyDemoClass);
Console.WriteLine("\nIs the specified type a class? {0}.", myType.IsClass);
}
catch(Exception e)
{
Console.WriteLine("\nAn exception occurred: {0}." ,e.Message);
}
}
}
The code above generates the following result.