博客
关于我
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/

你可能感兴趣的文章
Node-RED中使用node-red-node-ui-iframe节点实现内嵌iframe访问其他网站的效果
查看>>
Node-RED中使用Notification元件显示警告讯息框(温度过高提示)
查看>>
Node-RED中使用range范围节点实现从一个范围对应至另一个范围
查看>>
Node-RED中实现HTML表单提交和获取提交的内容
查看>>
Vue3+elementplus实现图片上传下载(最强实践)
查看>>
Node-RED中将CSV数据写入txt文件并从文件中读取解析数据
查看>>
Node-RED中建立TCP服务端和客户端
查看>>