Skip to Main Content
C# in a Nutshell
book

C# in a Nutshell

by Ben Albahari, Ted Neward, Peter Drayton
March 2002
Intermediate to advanced content levelIntermediate to advanced
864 pages
31h 8m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell

Namespaces

The general pattern to follow when naming namespaces is:

CompanyName.TechnologyName

Some examples of well-formed namespaces are:

Microsoft.Office
Corel.OfficePerfect 
OReilly.CSharpInANutshell

One problem that may arise, particularly as more companies begin to write code for the .NET platform, is that the “company-level” namespaces may clash. Java sought to avoid this problem by strongly suggesting companies use their reverse-DNS name (“oreilly.com” produces “com.oreilly” top-level namespace names), since DNS names are guaranteed to be unique. Over time, however, this proved to be less of an issue than originally thought, and many companies began to use the “center” name in the DNS name (for instance “oreilly” in “oreilly.com”). There is no reason to believe this convention won’t continue to work in .NET.

For legibility, use Pascal case, and separate logical components with periods (for example, Microsoft.Office.PowerPoint). However, if your product involves nontraditional capitalization, it’s okay to use that system, even if it deviates from normal namespace casing (for example NeXT.WebObjects, OReilly.Network and ee.cummings).

Plural namespace names are recommended where appropriate — for example, use System.Collections, not System.Collection. Exceptions to this rule are brand names and abbreviations — for example, use System.IO not System.IOs.

Never reuse names across namespace and class names — for example, the System.Debug namespace should never have a class named Debug ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# 8.0 in a Nutshell

C# 8.0 in a Nutshell

Joseph Albahari, Eric Johannsen
C# 10 in a Nutshell

C# 10 in a Nutshell

Joseph Albahari
C# in a Nutshell, Second Edition

C# in a Nutshell, Second Edition

Peter Drayton, Ben Albahari, Ted Neward
Code like a Pro in C#

Code like a Pro in C#

Jort Rodenburg

Publisher Resources

ISBN: 0596001819Catalog PageErrata