Tema: Operador IS
Ver Mensaje Individual
  #9  
Antiguo 04-08-2004
Avatar de jachguate
jachguate jachguate is offline
Miembro
 
Registrado: may 2003
Ubicación: Guatemala
Posts: 6.254
Reputación: 28
jachguate Va por buen camino
Cool

Cita:
Empezado por barman
¿Cual era la pregunta?


Cita:
Empezado por barman
no tengo ni idea de los que hace el is de delphy
mejor dejo que el propio delphi se explique:

Cita:
Empezado por delphi help
The is operator, which performs dynamic type checking, is used to verify the actual runtime class of an object. The expression

object is class

returns True if object is an instance of the class denoted by class or one of its descendants, and False otherwise. (If object is nil, the result is False.) If the declared type of object is unrelated to class—that is, if the types are distinct and one is not an ancestor of the other—a compilation error results. For example,

if ActiveControl is TEdit then TEdit(ActiveControl).SelectAll;

This statement casts a variable to TEdit after first verifying that the object it references is an instance of TEdit or one of its descendants.
De esta cuenta, que las siguientes operaciones resultarian en:

siendo miGrid un TDBGrid:
Código:
miGrid is TDBGrid          (true)  miGrid si es un TdbGrid
miGrid is TCustomControl   (true)  miGrid si es un TdbGrid
miGrid is TComponent       (true)  miGrid si es un TdbGrid
miGrid is TObject          (true)  miGrid si es un TdbGrid
miGrid is TStringGrid      (falso) miGrid no es un TStringGrid
Hasta luego.

__________________
Juan Antonio Castillo Hernández (jachguate)
Guía de Estilo | Etiqueta CODE | Búsca antes de preguntar | blog de jachguate
Responder Con Cita