0

Are there global members in .Net?

Every time I google I can find nothing about the global members, but while reading the CLR via C# I come across the following:

This causes ILDasm.exe to run, loading the Program.exe assembly. To see the metadata in a nice, human-readable form, select the View/MetaInfo/Show! menu item (or press CTRL+M). This causes the following information to appear:

===========================================================
ScopeName : Program.exe
MVID : {CA73FFE8-0D42-4610-A8D3-9276195C35AA}
===========================================================
Global functions
-------------------------------------------------------
Global fields
-------------------------------------------------------
Global MemberRefs
-------------------------------------------------------
TypeDef #1 (02000002)
-------------------------------------------------------
 TypDefName: Program (02000002)
 Flags : [Public] [AutoLayout] [Class] [Sealed] [AnsiClass] 
etc...

So, since the Global functions, the Global fields and the Global MemberRefs are not parts of any type, does that mean that there are global members in .Net?

iloveseven
  • 605
  • 4
  • 18
  • Technically no, there isn't a concept of Globals... Static would be the closest solution. [See here](https://www.arclab.com/en/kb/csharp/global-variables-fields-functions-static-class.html#targetText=A%20global%20variable%20is%20a,or%20class%20within%20the%20namespace.) or [this SO question](https://stackoverflow.com/questions/14368129/how-to-use-global-variables-in-c) – Anu6is Oct 22 '19 at 19:32
  • @Anu6is, thank you for your comment. But your comment does not make clear what the Global functions, the Global fields and the Global MemberRefs mean in the result produced by the `ILDasm.exe`. – iloveseven Oct 22 '19 at 20:22
  • 1
    Global members are members of the special `` class (ECMA-335, Partition II, Section 10.8 - Global fields and methods). C# doesn't support global members but other languages might. – Brian Reichle Oct 25 '19 at 05:35
  • @BrianReichle, can I access the `` class from C# somehow? – iloveseven Oct 26 '19 at 14:12
  • The referenced section of the spec seems to suggest that you can reference the global members through reflection, though I have never tried. – Brian Reichle Oct 28 '19 at 04:56

0 Answers0