Skip to content

Instantly share code, notes, and snippets.

@ufcpp
Created February 1, 2015 08:07
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 ufcpp/d1a5da1b5e44d3d8e56c to your computer and use it in GitHub Desktop.
Save ufcpp/d1a5da1b5e44d3d8e56c to your computer and use it in GitHub Desktop.
Overwriting a ref parameter
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