Skip to content

JA CSharp Keyword global

Codex edited this page Oct 11, 2026 · 2 revisions

Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

C#: global

ディレクトリ C# · 実践的な指導

global:: 修飾子は、ルート名前空間から検索を開始します。 global using は、すべてのプロジェクト ファイルに名前をインポートします。

簡単な例 (Example.cs)

この例を Example.cs として別に保存し、このページの他の例とは独立して実行してください。

Example.cs:

// PROJECT-EXAMPLE
global::System.Console.WriteLine("Root namespace");

結果:

Root namespace

構文

global::System.Console / global using Namespace;

例 1: 基本形式

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

public static class Program
{
    public static async Task Main(string[] args)
    {
        global::System.Console.WriteLine("Root namespace");
    }
}

例 2: 別の実用的な形式

global using System;
public static class Program { public static void Main() { Console.WriteLine("Shared import"); } }

公式ソース: Microsoft Learn。

Clone this wiki locally