如何全局函数在C#中存在吗? [英] How can global function exist in C#?

查看:325
本文介绍了如何全局函数在C#中存在吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何全局函数在C#中存在当一切都在类中定义的?我读 OpCodes.Call 的文档在MSDN, ,惊讶地看到下面的措辞,

How can global function exist in C# when everything is defined inside a class? I was reading the documentation of OpCodes.Call at MSDN, and was surprised to see the following wordings,

的元数据标记携带足够的信息来确定呼叫是否是一个静态方法,一个实例方法,虚拟方法,或全局函数。

The metadata token carries sufficient information to determine whether the call is to a static method, an instance method, a virtual method, or a global function.

全局功能?它是否在C#中存在吗? (这绝对不是指静态的方法,因为它具有全局功能一起明确列出)。

Global function? Does it exist in C#? (It definitely doesn't refer to static method, as it's explicitly listed along with global function).

推荐答案

您不能全局函数在C#中,它只是没有语言的一部分。你必须使用一个静态方法上的一些类您选择,以获得类似的功能。

You can't have global functions in C#, it's just not part of the language. You have to use a static method on some class of your choosing to get similar functionality.

但是C#是不是使用CLR的唯一语言。人们可以编写托管C ++,它可以有全局函数。

However C# is not the only language that uses the CLR. One can write Managed C++, which can have global functions.

这篇关于如何全局函数在C#中存在吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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