Saturday, 15 April 2017

C# NAMESPACES ~ mkniit

C# NAMESPACES

Namespace is a set of retaining the name provides a way to separate the other is designed for. The name of the class that is declared in a namespace declared in the same class name does not conflict with another.

Define a Namespace

Namespace definition keywords namespace namespace name is followed by the following:


define a namespace c#

Call it this version is activated by the function or variable namespace, add the name of the namespace as follows:



introducing a namespace c#

The following program demonstrates use of namespaces:

example sintax a namespace c#

When the above code is compiled and executed, it produces the following result:

result of example sintax a namespace c#

The Use of Keywords

The use of keywords indicate that this program uses names in a particular namespace. For example, we use the System namespace in our program. There is a defined class of console. We simply write:

namespace c#



We could have written the fully qualified name as:

namespace

You can also avoid placing namespaces with the using namespace directive. This directive tells the compiler that the next code makes use of the name in a particular namespace. Namespace then implied for the following code:

Let's rewrite our previous example, using the instructions:

sampe project namespace c#

When the above code is compiled and executed, it produces the following result:

namespace example c#
Nested Namespaces


You can define one namespace inside another namespace as follows:

nested namespace c#

You can access members of nested namespace by using the dot (.) operator as follows:

namespace c# example

When the above code is compiled and executed, it produces the following result:

result of example sintax a namespace c#

No comments:

Post a Comment