# Namespaces in .NET (C#): Organizing Code & Avoiding Conflicts
> Learn how to use C# namespaces to organize code, prevent naming collisions, and manage large .NET projects with best practices and code examples.

Tags: c-sharp, dotnet, programming, software-architecture, coding-best-practices, namespaces
## Namespaces in .NET (C#)
* **Overview**: Introduction to organizing code and preventing name conflicts.

## What is a Namespace?
* **Definition**: A logical container for classes, interfaces, structs, enums, and delegates.
* **Analogy**: Works like folders on a computer to group related types.

## Motivation for Using Namespaces
* **Scalability**: Handles thousands of classes in large projects.
* **Collaboration**: Facilitates team work and third-party library integration.
* **Conflict Prevention**: Keeps identical class names separate with unique identifiers.

## Syntax and Declaration
* **Accessing**: Use full paths like `CompanyName.ProjectName.Module.Customer` or the `using` directive for shortcuts.

## Key .NET Features
* **Nested Namespaces**: Create hierarchy in large projects.
* **using Alias**: Shorten long namespaces (e.g., `using MyAlias = System.Collections.Generic`).
* **Global using**: Available in C# 10+, allows project-wide declarations in one file.

## Common .NET Namespaces
* **System**: Core types like String and Console.
* **System.Collections.Generic**: Information on Lists, Dictionaries, and Queues.
* **System.Linq**: For querying collections.
* **System.IO**: File and stream operations.
* **Microsoft.EntityFrameworkCore**: ORM for database connections.

## Best Practices & Guidelines
* Use hierarchical names following `Company.Product.Feature`.
* Map namespace structures to physical folder structures.
* Avoid global namespace pollution by always wrapping types in a namespace.
---
This presentation was created with [Bobr AI](https://bobr.ai) — an AI presentation generator.