Namespaces group types and prevent name collisions. The Base Class Library lives under System.*—hence System.Collections.Generic.List<T> and System.Console.
using directives
using System;
using System.Collections.Generic;
namespace MyApp.Utils {
public static class MathHelper {
public static int Double(int x) => x * 2;
}
}
using imports namespaces so you can write List<int> instead of the fully qualified name. File-scoped namespaces (namespace MyApp;) reduce indentation in modern C#.
Important interview questions and answers
- Q: namespace vs assembly?
A: Namespaces organize source-level names; assemblies are deployment units (.dll) containing IL—the CLR loads assemblies, not namespaces directly. - Q: global using?
A: SDK-style projects can declareglobal using System;once for the whole project—common in .NET 6+ templates.
Self-check
- What keyword imports a namespace?
- Where does Console live by default?
Tip: Namespaces organize source names; assemblies are deployment units—the CLR loads .dll files, not namespaces directly.
Interview prep
- namespace vs assembly?
Namespaces organize source-level names; assemblies are deployment units (.dll) containing IL—the CLR loads assemblies.
- What is a global using?
global using System;applies to the entire project—reduces boilerplate in SDK-style templates.