Created
February 1, 2015 08:07
-
-
Save ufcpp/d1a5da1b5e44d3d8e56c to your computer and use it in GitHub Desktop.
Overwriting a ref parameter
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
using System; | |
class Point | |
{ | |
public int X { get; set; } | |
public int Y { get; set; } | |
} | |
class Program | |
{ | |
static void Main() | |
{ | |
var p = new Point(); | |
X(ref p); | |
Console.WriteLine($"{p.X}, {p.Y}"); // 10, 20 | |
} | |
static void X(ref Point p) | |
{ | |
p.X = 10; | |
p.Y = 20; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment