How do you use Namespaces?

Nate Bross

Contributor
Joined
Apr 6, 2005
Messages
601
Location
Chicago, IL
Which of these methods do you use, and why?

C#:
namespace some.longish.winded.name.space
{
    class something
    {
    }
}

or

C#:
namespace some
{
    namespace longish
    {
        namespace winded
        {
            namespace name
            {
                namespace space
                {
                    class something
                    {
                    }
                }
            }
        }
    }
}

Clearly the second approach leads to much greater level of indentation, which could be annoying on a small screen.

What advantages do you see to one over the other?
 
I tend to use the first version when all classes in a file are part of the same namespace - it is less typing and easier to read.

If I have more than one namespace in a single file (not common and I don't think I've ever had more than one namespace plus a single nested namespace) then the second form can sometimes be more readable.
 
Back
Top