为什么和在哪里使用私有构造函数 [英] why and where we use private constructor

查看:82
本文介绍了为什么和在哪里使用私有构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么以及在何处需要在带有c#的asp.net中使用私有构造函数

why and where we need to use private constructor in asp.net with c#
and whats the usage of it??

推荐答案

当您声明带有Private访问修饰符的构造方法时,它称为Private构造方法.我们可以在具有静态方法的单例模式或类中使用私有构造函数,例如某些实用程序类.
When you declare a Constructor with Private access modifier then it is called Private Constructor. We can use the private constructor in singleton pattern or class that has only static methods, like some utility class.


Only 117,000 results in this google search.
The very first link on the page has your answer right in the summary never mind having to actually click on it.

Google is your friend and should always be the first option for finding answers. That is the initiative we expect people to show before we provide help.


这篇关于为什么和在哪里使用私有构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆