referencia al objeto actual
DESCRIPTION
REFERENCIA AL OBJETO ACTUAL. MIGUEL MACIP CONTRERAS DIEGO ROGELIO PARRA MARIN CARLA PATRICIA VIVANCO GARCIA. REFERENCIA AL OBJETO ACTUAL. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: REFERENCIA AL OBJETO ACTUAL](https://reader036.vdocumento.com/reader036/viewer/2022082408/56812fda550346895d9551fd/html5/thumbnails/1.jpg)
REFERENCIA AL OBJETO ACTUAL
MIGUEL MACIP CONTRERASDIEGO ROGELIO PARRA MARIN
CARLA PATRICIA VIVANCO GARCIA
![Page 2: REFERENCIA AL OBJETO ACTUAL](https://reader036.vdocumento.com/reader036/viewer/2022082408/56812fda550346895d9551fd/html5/thumbnails/2.jpg)
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.
![Page 3: REFERENCIA AL OBJETO ACTUAL](https://reader036.vdocumento.com/reader036/viewer/2022082408/56812fda550346895d9551fd/html5/thumbnails/3.jpg)
EJEMPLO
Persona (string Nombre, int Edad, string NIF){ this.Nombre = Nombre; this.Edad = Edad; this.NIF = NIF;}
![Page 4: REFERENCIA AL OBJETO ACTUAL](https://reader036.vdocumento.com/reader036/viewer/2022082408/56812fda550346895d9551fd/html5/thumbnails/4.jpg)
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.
![Page 5: REFERENCIA AL OBJETO ACTUAL](https://reader036.vdocumento.com/reader036/viewer/2022082408/56812fda550346895d9551fd/html5/thumbnails/5.jpg)
GRACIAS