using directive with whole program scope

前端 未结 3 811
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-28 18:26

How can I have a using directive that has a scope of the whole program instead of just the file it is in. For every module that I use I would only want to set this once. If ther

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-28 19:23

    This is not possible. Fortunately.

    Just wondering why you want to do this. This would be a bad programming habit anyway - put concerns and dependencies only when you really need them. If you add the same using directives everywhere, you also need the referenced assemblies everywhere, something you really don't want to do. Your project should rely on assemblies it needs, no more, no less.

    Your argument about wasting time is a bit strange; if you loose so much time, you might have another problem in your architecture.

    Note: Resharper is a tool that you may find useful.

提交回复
热议问题