c# - How to get all namespace in project by assembly? -
this question has answer here:
i want namespace in main project method assembly.(not aseembly)
i read below question not useful.
for example
class in assembly:
namespace test { public class class1 { public string[] allnamespace() { return assembly.getexecutingassembly().gettypes().select(x => x.namespace).toarray(); } } }
code in main project:
namespace consoleapplication1 { class program { static void main(string[] args) { var util=new class1(); console.writeline(string.join(",",util.allnamespace()));//return test console.readkey(); } } }
return "test" want contain consoleapplication1 namespace.
use assembly.getcallingassembly
instead of assembly.getexecutingassembly
, should consoleapplication1
-assembly.
you namespaces of assembly, sure contain consoleapplication1
, not only.
Comments
Post a Comment