使用场景:

1.频繁IO操作,但很少改变的资源,例如:配置文件信息读取,日志操作。

2.资源控制,线程池。

UML图

    public class Config
    {
        private Config()
        {
        }
        private static Config instance = new Config();
        public static Config GetConfig()
        {
            return instance;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var config = Config.GetConfig();
        }
    }

 

posted on 2018-05-29 13:48  chester·chen  阅读(88)  评论(0编辑  收藏  举报