Skip to content

Instantly share code, notes, and snippets.

@rpjohnst
Created August 14, 2017 18:22
Show Gist options
  • Save rpjohnst/3c2f1d5f153afdbb39c05a3d3c0b35ed to your computer and use it in GitHub Desktop.
Save rpjohnst/3c2f1d5f153afdbb39c05a3d3c0b35ed to your computer and use it in GitHub Desktop.
using System;
namespace ValueTypes
{
struct Test
{
public int x { get; set; }
}
class Program
{
static void Main(string[] args)
{
var a = new Test { x = 1 };
Use(a, a);
Console.WriteLine(a.x); // 1
}
static void Use(Test b, Test c)
{
b.x = 2;
Console.WriteLine("{0} {1}", b.x, c.x); // 2 1
c.x = 3;
Console.WriteLine("{0} {1}", b.x, c.x); // 2 3
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment