Created
August 14, 2017 18:22
-
-
Save rpjohnst/3c2f1d5f153afdbb39c05a3d3c0b35ed to your computer and use it in GitHub Desktop.
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; | |
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