logo search
Учебник_ПОА

Example

The following example defines two namespaces, each containing a class named FileHandling. By specifying the namespace, it's possible to quickly differentiate between the classes and the methods they contain.

namespace StatisticalData

{

class FileHandling

{

public void Load() {} // code to load statistical data

}

}

namespace Images

{

class FileHandling

{

public void Load() {} // code to load an image file

}

}

class Program

{

static void Main()

{

StatisticalData.FileHandling data = new StatisticalData.FileHandling();

data.Load();

Images.FileHandling image = new Images.FileHandling();

image.Load();

}

}

Пример

В следующем примере определяются два пространства имен, в каждом их которых содержится класс с именем FileHandling. Указав пространство имен, можно быстро отличать одни классы от других, имеющих такие же имена.

------