Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void referencia(ref int y) //Quan cridem aquesta funció la y del main s'incrementa en 1 pq li hem passat la variable per referencia
- {
- y += 1;
- }
- static void no_referencia(int y) //Quan cridem aquesta funció la y del main es queda igual pq li hem passat una copia
- {
- y += 1;
- }
- static void main(string[] args)
- {
- int y = 1;
- referencia(y); //retorna y = 2
- y = 1;
- no_referencia(y); // retorna y = 1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement