IsClass Propiedad
TOC
Collapse the table of content
Expand the table of content
Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

Type.IsClass (Propiedad)

 

Obtiene un valor que indica si Type es una clase o un delegado, es decir, no es un tipo de valor ni una interfaz.

Espacio de nombres:   System
Ensamblado:  mscorlib (en mscorlib.dll)

public bool IsClass { get; }

Valor de propiedad

Type: System.Boolean

Es true si Type es una clase; en caso contrario, es false.

Implementaciones

_Type.IsClass

This property returns true for classes as well as delegates. It returns false for value types (for structures and enumerations) even if they are boxed.

If the currentT:System.Type represents a type parameter in the definition of a generic type or generic method, this property always returns true.If the current T:System.Type represents a constructed generic type, this property returns true if the generic type definition is a class definition; that is, it does not define an interface or a value type.

System_CAPS_noteNota

This property returns true for Type instances that represent the T:System.Enum and T:System.ValueType classes. These two classes are the base types for enumerations and value types, respectively, but they are not enumerations or value types themselves. For more information, see the P:System.Type.IsValueTypeand P:System.Type.IsEnum properties.

The F:System.Reflection.TypeAttributes.ClassSemanticsMaskenumeration value distinguishes a type declaration as class or interface.However, both classes and value types are marked with the F:System.Reflection.TypeAttributes.Class attribute. If you retrieve the value of a type's Attributes property and use the F:System.Reflection.TypeAttributes.ClassSemanticsMask value to determine whether a type is a class instead of a value type, you must also call the P:System.Type.IsValueType property. The example for the T:System.Reflection.TypeAttributes enumeration contains additional information as well as anexample.

This property is read-only.

The following example creates an instance of a type and indicates whether the type is a class.

using System;
using System.Reflection;

public  class MyDemoClass
{
}

public class MyTypeClass
{
    public static void Main(string[] args)
    {
        try
        {
            Type  myType = typeof(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);
        }
    }
}

.NET Framework
Disponible desde 1.1
Portable Class Library
Compatible con: portable .NET platforms
Silverlight
Disponible desde 2.0
Windows Phone Silverlight
Disponible desde 7.0
Volver al principio
Mostrar:
© 2016 Microsoft