9. Namespaces & Assemblies
Part 1: Namespaces
1. What are Namespaces?
// Different classes with same name in different namespaces
namespace MyCompany.UI
{
public class Button { } // UI button
}
namespace MyCompany.Hardware
{
public class Button { } // Physical button sensor
}2. Declaring Namespaces
Block-scoped (Traditional)
File-scoped (C# 10.0+) - Modern ✅
Nested Namespaces
3. Using Directives
Basic using Statement
using static (C# 6.0+)
using Alias
Alias any Type (C# 12.0+)
Global using (C# 10.0+)
4. Implicit Usings (.NET 6.0+)
Enable in .csproj
Default Implicit Usings by Project Type
Add Custom Implicit Usings
Remove Implicit Usings
5. Namespace Best Practices
Part 2: Essential Namespaces Reference
Core Namespaces ⭐⭐⭐ (Must Know)
System
System.Collections.Generic
System.Linq
System.Threading.Tasks
System.IO
System.Text
Common Namespaces ⭐⭐ (Frequently Used)
System.Text.RegularExpressions
System.Threading
System.Diagnostics
System.Net.Http
System.Text.Json
System.Collections.Concurrent
Specialized Namespaces ⭐ (As Needed)
System.Reflection
System.Numerics
System.Security.Cryptography
Common Using Combinations by Scenario
Console Application
File I/O
Async Programming
Data Processing
Web API Client
Database Operations
Part 3: Assemblies
10. What are Assemblies?
11. Assembly Types
12. DLL vs EXE
DLL (Dynamic Link Library)
EXE (Executable)
DLL vs EXE Comparison
Feature
DLL
EXE
13. Strong Naming
14. Assembly Versioning
Version Format
Version Types
Semantic Versioning (SemVer)
15. Assembly Loading
Loading Methods
Probing Paths
16. Assembly Scope & Visibility
internal Access Modifier
InternalsVisibleTo Attribute
Part 4: Project Structure
17. .NET Project File (.csproj)
SDK-Style Project (Modern)
18. Solution Files (.sln)
19. NuGet Packages
20. Target Frameworks
Available Frameworks
Multi-Targeting
Framework Compatibility Matrix
Target
Can Reference
21. Project Organization Best Practices
Recommended Folder Structure
Namespace = Folder Path
Best Practices
Separation of Concerns
Quick Reference Summary
Namespaces
Essential Namespaces
Assemblies
Project Organization
Last updated