Skip to Main Content
C# in a Nutshell, Second Edition
book

C# in a Nutshell, Second Edition

by Peter Drayton, Ben Albahari, Ted Neward
August 2003
Intermediate to advanced content levelIntermediate to advanced
928 pages
32h 1m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell, Second Edition

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 within ...

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# in a Nutshell

C# in a Nutshell

Ben Albahari, Ted Neward, Peter Drayton
C# 7.0 in a Nutshell

C# 7.0 in a Nutshell

Joseph Albahari, Ben Albahari
C# Cookbook, 2nd Edition

C# Cookbook, 2nd Edition

Jay Hilyard, Stephen Teilhet
C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard

Publisher Resources

ISBN: 0596005261Catalog PageErrata