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

你可能感兴趣的文章
netty——Channl的常用方法、ChannelFuture、CloseFuture
查看>>
netty——EventLoop概念、处理普通任务定时任务、处理io事件、EventLoopGroup
查看>>
netty——Future和Promise的使用 线程间的通信
查看>>
netty——Handler和pipeline
查看>>
Vue输出HTML
查看>>
netty——黏包半包的解决方案、滑动窗口的概念
查看>>
Netty中Http客户端、服务端的编解码器
查看>>
Netty中使用WebSocket实现服务端与客户端的长连接通信发送消息
查看>>
Netty中实现多客户端连接与通信-以实现聊天室群聊功能为例(附代码下载)
查看>>
Netty中的组件是怎么交互的?
查看>>