Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void IncrementAge(Person person)
- {
- Console.WriteLine($"Inside function => {person.Name}'s age before change: {person.Age}");
- person.Age += 1;
- Console.WriteLine($"Inside function => {person.Name}'s age after change: {person.Age}");
- person = null;
- }
- static void Main(string[] args)
- {
- var alice = new Person { Name = "Alice", Age = 17 };
- Console.WriteLine($"Inside main => {alice.Name}'s age before function call: {alice.Age}");
- IncrementAge(alice);
- Console.WriteLine($"Inside main => {alice.Name}'s age after function call: {alice.Age}");
- Console.ReadLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement