toplevel-statement

How do I get the Reflection TypeInfo of a C# 9 program that use Top-level statements?

∥☆過路亽.° 提交于 2020-12-12 05:39:42
问题 Assume I have a simple script writing in C# 9 like this: using System; using System.IO; // What to put in the ??? var exeFolder = Path.GetDirectoryName(typeof(???).Assembly.Location); Before, with the full program, we can use the Main class as an "indicator" class. this and this.GetType() is not available because technically it's inside a static method. How do I get it now? A workaround I thought of while typing the question is Assembly.GetCallingAssembly() : var exeFolder = Path