Defining Custom Namespaces
Before diving into the details of assembly deployment and configuration, it is very important to
examine the topic of creating custom .NET namespaces. Up to this point in the text, you have been
building small test programs leveraging existing namespaces in the .NET universe (System in partic-
ular). However, when you build your own custom applications, it can be very helpful to group your
related types into custom namespaces. In C#, this is accomplished using the namespace keyword.
This is even more important when creating .NET *.dll assemblies, as other developers will need to
import your custom namespaces to make use of your types.
Assume you are developing a collection of geometric classes named Square, Circle, and
Hexagon. Given their similarities, you would like to group them all together into a common custom
namespace. You have two basic approaches. First, you may choose to define each class within a
single file (ShapesLib.cs) as follows:
Do'stlaringiz bilan baham: |