We can organize our types based on their bahaviour and functionalities. For example consider the following example. Suppose you have a collection of songs, how will you store it in your computer? normally one do this by creating root folder named "Songs" then create sub folders based on song types, then create subfolders for albums etc....
Have a look on the following C# example to understand the advantages of the namespace.
namespace Songs
{
public class Songs
{
public void PlayAll()
{
Console.WriteLine("Playing all songs..");
}
}
namespace English
{
public class Titanic
{
public void Play()
{
Console.WriteLine("Playing titanic..");
}
}
}
namespace Malayalam
{
public class Urumi
{
public void Play()
{
Console.WriteLine("Playing urumi.....");
}
}
}
}
No comments:
Post a Comment