How can global function exist in C#?

Nawaz picture Nawaz · Sep 3, 2011 · Viewed 15.7k times · Source

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.

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

Answer

i_am_jorf picture i_am_jorf · Sep 4, 2011

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.

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