Created
August 4, 2021 21:30
-
-
Save manoj-choudhari-git/16a8c47a00d3c2a17eb5c8f0434e6852 to your computer and use it in GitHub Desktop.
.NET - C# Features - An experiment with Reference Type Parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReferenceTypeDemo | |
{ | |
public void Execute() | |
{ | |
Person p = new Person(); | |
p.Age = 25; | |
p.Name = "Sachin Tendulkar"; | |
Console.WriteLine("----------------------------------------------------------------"); | |
Console.WriteLine($"Inside Caller: Before ChangeObject : Value: {p}"); | |
ChangeObject(p); | |
Console.WriteLine($"Inside Caller: After ChangeObject : Value: {p}"); | |
} | |
private void ChangeObject(Person p) | |
{ | |
p = new Person(); | |
p.Age = 20; | |
p.Name = "MS Dhoni"; | |
Console.ForegroundColor = ConsoleColor.Green; | |
Console.WriteLine($"Inside ChangeObject: Value: {p}"); | |
Console.ResetColor(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment