Search⌘ K
AI Features

Namespaces and Using Directives

Explore how namespaces help organize related code and how using directives simplify code access in C#. Learn file scoped namespaces, global using directives introduced in C# 10, and using static to access class members easily. This lesson clarifies essential C# syntax for managing and calling code efficiently.

What is a namespace?

A namespace helps organize a large group of related code. To use a namespace, call it with the using directive or include it before the class name.

Syntax

namespace NamespaceExample1Console
{
  // Empty Namespace
}

// In C# 10 file scoped namespaces were introduced. The namespace below does
...