Back to Writing
NOTEScsharpnamespacesusing-directivealias

C# Using Directive - Resolving Namespace Conflicts with Aliases

October 7, 2020Updated Feb 17, 2026

![](

kg.SSshu4tCGzxR0_Lt-uUIRuNGc_8GKtMn_N-vgTmoAo0g.PNG.cdw0424/SE-b3a2f0e5-5c8e-4690-8102-5e7ae26690a1.png?type=w966)

I rarely encountered situations where class names across namespaces would conflict while using libraries, but it happened by chance. In the process of resolving it, I learned a new feature I didn't know existed.

Using Alias Directives

With the alias directive feature, you can:

![](

6UdQN4ci9nPFEbUP-Ug.YdAvK0QVzH2CpWVLmMU0GZ87ek1kdL6dPR2m2fThRJkg.PNG.cdw0424/image.png?type=w966)

To resolve this kind of conflict:

![](

vQ1M8DZd4B9hlwDMoUg.IIi7CuwT0IaTwb2wjOtQ9KlEtoyjJ3h_N2gl2M8io_Qg.PNG.cdw0424/image.png?type=w966)

By specifying the namespace this way, you can use only the specific class you want. Additionally:

![](

Ot7OJNtK-NqdqfCnV0g.TxdwxWHXK3N8CMUywhT58RPisoMUFPiQ9Con-qKjIGIg.PNG.cdw0424/image.png?type=w966)

Interestingly, as the feature name suggests, you can create separate aliases and rename types to entirely different identifiers. This seems like a very useful feature for educational purposes. It's equivalent to using "as" in Python's import statements.

Note that the code above is just to demonstrate the error resolution process and was written without much thought.


using directive - C# Reference