User Program Communication

Namespace in C#

Namespaces are used to group methods, classes, and other code into a package for use in many different files.

The .NET framework comes with many (including the popular System.IO), and in order to certain classes within the framework (like File), use of the namespace must be declared.


Syntax
namespace namespaceName {
    ///methods, classes, etc
}

///accessing a namespace member without 'using' it
namespaceName.memberName

///to access members of a namespace without the prefix
using namespaceName;

Notes

Many of the non-default namespaces require the importing of the dll file into the IDE.


Example
using System.IO;

///the Console class is actually a part of the System.IO namespace
Console.WriteLine("Hello, World!");

See Also
Documentation

namespace (C# Reference) - MSDN

Add to Slack

< Write to File   |   Primitive Data Types >

© 2018 SyntaxDB. All Rights Reserved.