Search code examples
c#namespaces.net-assembly

Is it good or bad coding practice to have multiple namespaces in single assembly C#?


I am creating a C# assembly which has logical folders in it. Every time I add a file into a folder it has a different namespace because of the folder.

I am curious that should I rename each one to same namespace or leave it as it is.

Which one is best practice?


Solution

  • Namespace organize code elements and creates globally unique types. If you want your code to be in a single namespace then sure you can rename all of them, but since you have your code in different folder for organization you can leave them in different namespace for clarity. But it depends on you and your requirement.