1 / 5

REFERENCIA AL OBJETO ACTUAL

REFERENCIA AL OBJETO ACTUAL. MIGUEL MACIP CONTRERAS DIEGO ROGELIO PARRA MARIN CARLA PATRICIA VIVANCO GARCIA. REFERENCIA AL OBJETO ACTUAL.

noah-jordan
Télécharger la présentation

REFERENCIA AL OBJETO ACTUAL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. REFERENCIA AL OBJETO ACTUAL MIGUEL MACIP CONTRERAS DIEGO ROGELIO PARRA MARIN CARLA PATRICIA VIVANCO GARCIA

  2. REFERENCIA AL OBJETO ACTUAL • Todo objeto puede hacer referencia a si mismo, mediante la palabra clave This(lo que se conoce como una referencia this). En un método, la referencia this puede utilizarse en forma implícita y explicita para hacer referencia a las variables de instancia y otros métodos del objeto en el cual se haya llamado.

  3. EJEMPLO • Persona (string Nombre, int Edad, string NIF){this.Nombre = Nombre;this.Edad = Edad;this.NIF = NIF;}

  4. Es decir, dentro de un método con parámetros cuyos nombres coincidan con campos, se da preferencia a los parámetros y para hacer referencia a los campos hay que prefijarlos con el this tal y como se muestra en el ejemplo.

  5. GRACIAS

More Related