博客
关于我
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分表后同结构不同名称表之间复制数据以及Update语句只更新日期加减不更改时间
查看>>
mySql分页Iimit优化
查看>>
MySQL分页查询
查看>>
WebDriverException:未知错误:对于旧版本的 Google Chrome,在 Python 中找不到带有 Selenium 的 Chrome 二进制错误
查看>>
mysql列转行函数是什么
查看>>
mysql创建函数报错_mysql在创建存储函数时报错
查看>>