使用静态构造函数 [英] use of static constructor
本文介绍了使用静态构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
静态构造函数和静态类的用途是什么,请举例说明
what is the use of static constructor & static class please explain with example
推荐答案
hi,
使用静态类包含不与特定对象关联的方法.例如,通常需要创建一组不作用于实例数据并且不与代码中的特定对象相关联的方法.您可以使用静态类来保存这些方法.
静态构造函数用于初始化任何静态数据,或执行仅需要执行一次的特定操作.在创建第一个实例或引用任何静态成员之前,将自动调用它.
问候,
shefeek
Use a static class to contain methods that are not associated with a particular object. For example, it is a common requirement to create a set of methods that do not act on instance data and are not associated to a specific object in your code. You could use a static class to hold those methods.
A static constructor is used to initialize any static data, or to perform a particular action that needs performed once only. It is called automatically before the first instance is created or any static members are referenced.
regards,
shefeek
这可能对您有帮助,
静态构造函数 [静态类和静态类成员 [
It might help you,
Static Constructors [^]
Static Classes and Static Class Members[^]
:)
浏览以下链接:
静态类:
http://msdn.microsoft.com/en-us/library/79b3xss3 (v = vs.80).aspx [ http://msdn.microsoft.com/en-us/library /k9x6w0hc(v=vs.80).aspx#Y200 [
Go through these links:
Static Class:
http://msdn.microsoft.com/en-us/library/79b3xss3(v=vs.80).aspx[^]
Static Constructor:
http://msdn.microsoft.com/en-us/library/k9x6w0hc(v=vs.80).aspx#Y200[^]
这篇关于使用静态构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文