Skip to content

FR CSharp Keyword global

Codex edited this page Oct 11, 2026 · 2 revisions

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

C#: global

Manuel C# · Guide pratique

Le qualificatif global:: démarre la recherche à partir de l'espace de noms racine ; global using importe les noms dans tous les fichiers du projet.

Exemple simple (Example.cs)

Enregistrez cet exemple séparément dans Example.cs. Exécutez-le indépendamment des autres exemples de cette page.

Example.cs:

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

Résultat:

Root namespace

Syntaxe

global::System.Console / global using Namespace;

Exemple 1 : formulaire de base

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");
    }
}

Exemple 2 : une autre forme pratique

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

Source officielle : Microsoft Apprendre.

Clone this wiki locally