C# struct
2022-09-13 16:38 qgbo 阅读(38) 评论(0) 收藏 举报C# struct
struct Point{ public int X; public int Y; }
var p1= new Point(){X=1,Y=1}
var p2= new Point(){X=1,Y=1}
p1.X=123;
var p3=p1;
hashcode of p1 and p2 is the same!
if p1 change its` some property, the hashcode will change!
hashset<point> can work when we need judge repeat
if we change the struct into class, all will reverse!
气功波(18037675651)
浙公网安备 33010602011771号