In C#, you can do:
namespace Blah
{
namespace Foo
{
}
}
Or:
namespace Blah.Foo
{
}
Which should I prefer, if either? The bottom one is somewhat cleaner in terms of braces, but I don’t know if it has the same properties.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Both behave equally, and I strongly prefer the second one.
Usually, people prefer having 1 .cs file per class/interface, or at least for groups of similar ones (e.g., all Tuple implementations), which means you usually have 1 namespace in a .cs file anyway.
Nested Namespaces add levels of indentation. Usually, you are already 3 levels deep (namespace, class, method) for each piece of code that you write, so why add even more unnecessary indentations?