Buscar
Estás en modo de exploración. debe iniciar sesión para usar MEMORY

   Inicia sesión para empezar


Por supuesto:

Advanced Concept C# Interview Questions

» Iniciar este curso
(Practica preguntas similares gratis)
Pregunta:

How do ref and out keywords work in C#, and how do they relate to Call By Reference?

Autor: Lock Huynh



Respuesta:

In C#, the ref and out keywords are used to pass arguments by reference, allowing methods to modify the original variable. ref: Requires the variable to be initialized before passing to the method. It allows both reading and modifying the variable inside the method. out: Does not require the variable to be initialized before passing. The method must assign a value to the variable before it returns. Both ref and out enable Call By Reference, allowing methods to modify the caller's original data rather than a copy.


0 / 5  (0 calificaciones)

1 answer(s) in total