博客
关于我
C#设计模式02——原型模式的写法
阅读量:425 次
发布时间:2019-03-06

本文共 434 字,大约阅读时间需要 1 分钟。

public class ProteType    {             private static ProteType _ProteType = new ProteType();        private ProteType() { }        public static ProteType GetInstance()        {            return (ProteType)_ProteType.MemberwiseClone();        }            }

运行测试

var a1 = ProteType.GetInstance();                var a2 = ProteType.GetInstance();                Console.WriteLine($"a1 和 a2 是同一实例:{ object.ReferenceEquals(a1, a2)}");

 

转载地址:http://yxiuz.baihongyu.com/

你可能感兴趣的文章
Mysql下载以及安装(新手入门,超详细)
查看>>
MySQL不会性能调优?看看这份清华架构师编写的MySQL性能优化手册吧
查看>>