Thoughts from the office by Ed Ball
Wednesday, March 10, 2004

From the Namespace Naming Guidelines of the Design Guidelines for Class Library Developers:

Do not use the same name for a namespace and a class. For example, do not provide both a Debug namespace and a Debug class.

If you want to avoid bizarre C# compiler errors, you would do well to follow this rule. In fact, don't give classes the same name as any part of any nested namespace. For example, if there's a MyCompany.MyFeature.MyLibrary namespace, you should avoid defining a MyCompany, MyFeature, or MyLibrary class, in that namespace or any other.

It ultimately comes down to conflicts with the using-namespace statements that you'll probably try to use. I've played around with it a bit and have been unable to put my finger on the method to the madness. When writing libraries, it is often tempting to create a class with the same name as the last part of the namespace; don't do it.

3/10/2004 4:17:05 PM (Pacific Standard Time, UTC-08:00) | Comments [0] | Code#
Search
Archive
Links
Categories
Administration
Blogroll