Namespace using statements in C#

This post explores different approaches to declaring namespace using statements in C#.

The Conventional Approach (Outer)

The most common method places using statements outside the namespace scope, typically organized with .NET framework namespaces first, followed by other frameworks and internal dependencies.

Inner Declarations

An alternative approach places using statements within the namespace scope itself, keeping them closer to where they're used.

Namespace Shortening

A lesser-known technique allows shortening namespace declarations when inside a parent namespace. For example, within the AwesomeApp namespace, you can write using Contracts; instead of using AwesomeApp.Contracts;.

The Recommended Hybrid Approach

I advocate combining these techniques strategically:

using System.Transactions;

namespace AwesomeApp
{
    using System;
    using Contracts;
    using Model;
}

I describe this hybrid method as the crème de la crème regarding declaring namespaces in C#—placing framework-level dependencies outside the namespace while moving application-specific imports inside and utilizing namespace shortening where applicable.