Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. class Program
  2. {
  3. static void IncrementAge(Person person)
  4. {
  5. Console.WriteLine($"Inside function => {person.Name}'s age before change: {person.Age}");
  6. person.Age += 1;
  7. Console.WriteLine($"Inside function => {person.Name}'s age after change: {person.Age}");
  8. person = null;
  9. }
  10.  
  11. static void Main(string[] args)
  12. {
  13. var alice = new Person { Name = "Alice", Age = 17 };
  14. Console.WriteLine($"Inside main => {alice.Name}'s age before function call: {alice.Age}");
  15. IncrementAge(alice);
  16. Console.WriteLine($"Inside main => {alice.Name}'s age after function call: {alice.Age}");
  17.  
  18. Console.ReadLine();
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement