class Hexagon{ /* More interesting methods... */ }
class Square{ /* Even more interesting methods... */ }
Notice how the MyShapes namespace acts as the conceptual “container” of these types. Alterna-
tively, you can split a single namespace into multiple C# files. To do so, simply wrap the given class
definitions in the same namespace:
// circle.cs
using System;
namespace MyShapes
{
// Circle class
class Circle{ }
}
// hexagon.cs
using System;
namespace MyShapes
{
// Hexagon class
class Hexagon{ }
}
// square.cs
using System;
namespace MyShapes
{
// Square class
class Square{ }
}
When another namespace wishes to use objects within a distinct namespace, the using key-
word can be used as follows:
Do'stlaringiz bilan baham: