How do you get the root namespace of an assembly?

前端 未结 13 2017
后悔当初
后悔当初 2020-12-01 11:41

Given an instance of System.Reflection.Assembly.

13条回答
  •  忘掉有多难
    2020-12-01 12:15

    I just created an empty internal class called Root and put it in the project root (assuming this is your root namespace). Then I use this everywhere I need the root namespace:

    typeof(Root).Namespace;
    

    Sure I end up with an unused file, but it's clean.

提交回复
热议问题