为什么一个静态构造函数没有任何参数 [英] Why a Static Constructors do not have any parameters

查看:478
本文介绍了为什么一个静态构造函数没有任何参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据MSDN:

静态构造函数并不需要访问修饰符或有参数。

一个静态构造函数被自动调用初始化类创建的第一个实例之前或任何静态成员被引用。

A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.

一个静态构造函数不能直接调用。

A static constructor cannot be called directly.

任何一个可以请解释为什么静态构造函数不能带参数。

Can any one please explain why the static constructor can not have parameters.

推荐答案

由于MSDN说, 静态构造函数被自动调用初始化类的第一个实例被创建的。因此,你不能把它的参数。

As MSDN says, A static constructor is called automatically to initialize the class before the first instance is created. Therefore you can't send it any parameters.

如果在CLR必须调用静态构造函数将如何知道哪些参数传递给它?

If the CLR must call a static constructor how will it know which parameters to pass it?

这篇关于为什么一个静态构造函数没有任何参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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