Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Created August 4, 2021 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/16a8c47a00d3c2a17eb5c8f0434e6852 to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/16a8c47a00d3c2a17eb5c8f0434e6852 to your computer and use it in GitHub Desktop.
.NET - C# Features - An experiment with Reference Type Parameters
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