---
title: "静态的实例【单例模式中】"
author: "Perrin Yong"
author_profile: https://www.pystone.net/profile/
published_by: "Perrin Yong"
canonical: https://www.pystone.net/notes/csharp-static-instance-singleton/
type: note
content_role: unspecified
visibility: public
id_stability: rename-stable
source_path: "10-计算机、信息技术与工程/02-编程语言与运行时/.NET与CSharp/静态的实例【单例模式中】.md"
content_hash: 4da95764973558a7dcba47ed9d1e4dd8961788dbfc8a69618e299a54f15d8d6c
knowledge_version: 224c990773de.5fa8af6e39fa
site_commit: 224c990773de166d23a886306577dd90379529ce
notes_commit: 5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a
---
# 静态的实例【单例模式中】

﻿# 静态的实例【单例模式中】

> 创建时间：2020/9/14 14:39

静态的实例可以作为静态函数和动态函数之间的桥梁。

静态函数不能调用动态函数，因此，如果想用静态函数调用动态函数，就可以使用静态的实例（单例模式中的Instance）。

静态函数不能直接调用动态函数的原因是：静态函数可以在类实例化之前调用，而此时，无法确定类是否被实例化。动态函数是类的动态实例才有的成员，静态语句没有直接访问动态函数的途径。

如果写一个静态的实例，就可以保证类在被静态地访问到时，就已经有一份实例，可以访问到动态函数。
