Using aliases in C# to provide shorthand references to types or namespaces

In C# we can use aliases to provide shorthand references to types or namespaces.

Aliases can be useful to tidy up our code for example when we might be repeatability referencing generic types. They also help to remove ambiguity when we have conflicting type names in difference namespaces. In this case without aliases we would have to put the full reference to the type in our code.

Of course aliases can be misused so be careful to not reduce readability when using them.

Leave a Reply

Your email address will not be published.