Last active
October 30, 2018 12:07
-
-
Save zzandy/3ff62bea1e5111136b6ac9459b988243 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public struct Struct { public int Prop { get; set; } } | |
public class Class { public int Prop { get; set; } } | |
public static Class Change(Class cls) { cls.Prop = 1; return cls; } | |
public static Struct Change(Struct str) { str.Prop = 1; return str; } | |
... | |
var str = new Struct() { Prop = 2 }; | |
var cls = new Class() { Prop = 2 }; | |
var str2 = str; | |
var cls2 = cls; | |
str2.Prop = 3; | |
cls2.Prop = 3; | |
Console.WriteLine(str.Prop == str2.Prop); | |
Console.WriteLine(cls.Prop == cls2.Prop); | |
Console.WriteLine(str.Prop == Change(str).Prop); | |
Console.WriteLine(cls.Prop == Change(cls).Prop); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment