Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Type.IsClass Property

Gets a value indicating whether the Type is a class; that is, not a value type or interface.

[Visual Basic]
Public ReadOnly Property IsClass As Boolean
public bool IsClass {get;}
public: __property bool get_IsClass();
public function get IsClass() : Boolean;

Property Value

true if the Type is a class; otherwise, false.


This property returns true for Type instances representing Enum and ValueType.

The ClassSemanticsMask distinguishes a type declaration as class, interface, or value type.

This property is read-only.


[Visual Basic, C#, C++] The following example creates an instance of a type and indicates whether the type is a class.

[Visual Basic] 
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic
Public Class MyDemoClass
End Class 'MyDemoClass
Public Class MyTypeClass
    Public Shared Sub Main()
            Dim myType As Type = Type.GetType("MyDemoClass")
            ' Get and display the 'IsClass' property of the 'MyDemoClass' instance.
            Console.WriteLine(ControlChars.Cr + "Is the specified type a class? {0}.", myType.IsClass.ToString())
        Catch e As Exception
            Console.WriteLine(ControlChars.Cr + "An exception occurred: {0}.", e.Message.ToString())
        End Try
    End Sub 'Main
End Class 'MyTypeClass

using System;
using System.Reflection;
public  class MyDemoClass
public class MyTypeClass
    public static void Main(string[] args)
            Type  myType=Type.GetType("MyDemoClass");
            // Get and display the 'IsClass' property of the 'MyDemoClass' instance.
            Console.WriteLine("\nIs the specified type a class? {0}.", myType.IsClass); 
        catch(Exception e)
            Console.WriteLine("\nAn exception occurred: {0}." ,e.Message);

#using <mscorlib.dll>

using namespace System;
using namespace System::Reflection;

public __gc class MyDemoClass {

int main() {
   try {
      Type*  myType=Type::GetType(S"MyDemoClass");
      // Get and display the 'IsClass' property of the 'MyDemoClass' instance.
      Console::WriteLine(S"\nIs the specified type a class? {0}.", __box( myType->IsClass));
   } catch (Exception* e) {
      Console::WriteLine(S"\nAn exception occurred: {0}." , e->Message);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Type Class | Type Members | System Namespace | TypeAttributes | IsInterface | IsValueType

© 2017 Microsoft