Free mag vol1 | Page 565

CHAPTER 14  BUILDING AND CONFIGURING CLASS LIBRARIES using My3DShapes; // Resolve the ambiguity using a custom alias. using The3DHexagon = My3DShapes.Hexagon; namespace CustomNamespaces { class Program { static void Main(string[] args) { // This is really creating a My3DShapes.Hexagon class. The3DHexagon h2 = new The3DHexagon(); ... } } } This alternative using syntax also lets you create an alias for a lengthy namespace. One of the longer namespaces in the base class library is System.Runtime.Serialization.Formatters.Binary, which contains a member named BinaryFormatter. If you wish, you can create an instance of the BinaryFormatter as follows: using bfHome = System.Runtime.Serialization.Formatters.Binary; namespace MyApp { class ShapeTester { static void Main(string[] args) { bfHome.BinaryFormatter b = new bfHome.BinaryFormatter(); ... } } } as well as with a traditional using directive: using System.Runtime.Serialization.Formatters.Binary; namespace MyApp { class ShapeTester { static void Main(string[] args) { BinaryFormatter b = new BinaryFormatter(); ... } } } 507