标签:object equal 对象 bsp 模式 vat OLE color this
例子:
public class ParmeraSingleton { private static ParmeraSingleton instance = null; private int x, y; private ParmeraSingleton(int x, int y) { this.x = x; this.y = y; } public static ParmeraSingleton GetInstance(int x, int y) { if(instance == null) { instance = new ParmeraSingleton(x, y); } else { instance.x = x; instance.y = y; } return instance; } public class Program { public static void Main(string[] args) { ParmeraSingleton s1, s2; s1 = ParmeraSingleton.GetInstance(1,2); s2 = ParmeraSingleton.GetInstance(2,3); Console.WriteLine(object.ReferenceEquals(s1,s2)); } }
标签:object equal 对象 bsp 模式 vat OLE color this
原文地址:https://www.cnblogs.com/sy-liu/p/13084302.html