如何创建公共对象 [英] how to create object as public

查看:55
本文介绍了如何创建公共对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果要创建类n,我想使用oops概念立即创建类的对象.mns我想在所有页面上使用此类.我们总是在我要创建一次并在所有页面中使用的所有页面bt中始终创建对象.

i want to create object of class at once..mns using oops concept if i create class n i want to use this class to all page. we alwayz create object in every page bt i want create once and use to all pages.

推荐答案

似乎您要创建一个全局"对象的实例.对于此要求,应使用单例模式.我相信从面向对象的编程角度来看,这是正确的方法.有关更多信息,请参见以下链接:
C#中的简单单例模式 [ http://msdn.microsoft.com/en-us/library/ff650316.aspx [ ^ ]
http://www.yoda.arachsys.com/csharp/singleton.html [ ^ ]
It looks like you want to create one instance of a "global" object. For this requirement, the singleton pattern should be used. I believe from an object oriented programming perspective, this is the right approach. See these links for more information:
Simple Singleton Pattern in C#[^]
http://msdn.microsoft.com/en-us/library/ff650316.aspx[^]
http://www.yoda.arachsys.com/csharp/singleton.html[^]


这篇关于如何创建公共对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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