EN CSharp Keyword namespace - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
C#: namespace
Organizes types and prevents name conflicts. You can use a block or file-scoped declaration.
Simple example (Example.cs)
Save this example separately as Example.cs. Run it independently of the other examples on this page.
Example.cs:
// PROJECT-EXAMPLE
namespace MyTools;
class Item { public string Name => "Ore"; }
Declaration only: this code compiles as a library; call it from Main to run it.
Syntax
namespace Name { ... } / namespace Name;
Example 1: simple form
using System; namespace GameTools { public static class Program { public static void Main() { Console.WriteLine(typeof(Program).FullName); } } }
Example 2: another practical form
using System; namespace MyTools; public static class Program { public static void Main() { Console.WriteLine(typeof(Program).Namespace); } }
Official source: Microsoft Learn.