?
Solved

Organizing a C# class library

Posted on 2009-05-11
3
Medium Priority
?
848 Views
Last Modified: 2012-05-06
How can a class library be organized, similar to Microsoft's libaries where classes are in a tree structure, i.e. namespace.class.subclass.subclass.method.
Classes in my current library are organized on an inheritance level, but I'd like to be use them as outlined above.
0
Comment
Question by:mtasking
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Expert Comment

by:zwei
ID: 24357042
If you're wondering about how to organize your files in namespaces or how to name your namespaces, looking at big open-source projects usually works to get an idea of the structure.

The general rule for naming namespaces is to use the company name followed by the technology name and optionally the feature and design as follows:

CompanyName.TechnologyName[.Feature][.Design]

Prefixing namespace names with a company name or other well-established brand avoids the possibility of two published namespaces having the same name. Use a stable, recognized technology name at the second level of a hierarchical name.

The dot operator separates namespaces and/or classes, not classes and subclasses. If you have class B that extends class A you can't do
ClassA.ClassB
0
 
LVL 39

Expert Comment

by:abel
ID: 24357072
You can put on top of each class, or in fact, surrounding any class, a "namespace" statement (different from a "using" directive). It looks as follows:

however, the inheritance is not so visible when you use the object browser. Instead, the object browser (I assume that's what you are referring to), shows the assemblies, and the assemblies usually follow the names of the namespaces (though some assemblies contain multiple namespaces and vice versa).

namespace myNameSpace.mySubNamespace   // you are free of choosing names here
{
   class myClass
   {
 
 
        class childClass
        {
        }
   }
 
 
}

Open in new window

0
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 24357125
Hi mtasking,;

To create a tree structure for your library you need to use a nested Namespace. See the below document.

From the Microsoft documentation: The namespace keyword is used to declare a scope. This namespace scope lets you organize code and gives you a way to create globally unique types.
http://msdn.microsoft.com/en-us/library/z2kcy19k(vs.80).aspx

Fernando
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question