The C# doc on the using directive says
The
usingdirective allows you to use types defined in a namespace without specifying the fully qualified namespace of that type.
I understood this to mean that if you want to use System.Console, you have two options -- either
- include a
using Systemdirective in your code which allows you to refer toSystem.Consolesimply asConsole; or, - fully-qualify
System.Console-- i.e. refer toSystem.ConsoleasSystem.Console.
Yet, I have the following C# code in Visual Studio Code and it works even though I didn't include a using System directive and even though I refer to System.Console as just Console
Console.WriteLine("Hello World!");
List<String> names = ["Alice", "Bob", "Eve"];
foreach (String name in names) {
Console.WriteLine($"Hello {name}!");
}
Consolelives in theSystemnamespaceListlives in theSystem.Collections.Genericnamespace
I am neither fully-qualifying System.Console nor did I include a using System directive.
Similarly for List.
Yet, the code runs fine and prints the following the console:
Hello World!
Hello Alice!
Hello Bob!
Hello Eve!