C# has had the ability to alias namespaces and named types for a long time. It’s useful for avoiding naming conflicts between libaries or for using simpler names for complex generic types. If you’re not familiar with namespace and type aliasing, here is an example:
permalinkNew Aliasable Types
With the release of C# 12, developers are gaining the ability to alias almost all types. Let’s review some of the new options.
permalinkAliasing Tuple Types
Tuples are commonly used as method return types, but when they’re used multiple times, aliasing can help us keep our code cleaner and more legible.
permalinkAliasing Types with Pointers
Most of time, C# developers don’t need access to pointers, but now you can alias them when you do.
permalinkAliasing Array Types
Aliased array types are another addition in C# 12, which should make your declarations cleaner and more legible for teams.
permalinkAliasing Nullable Types
Most types are available for aliasing in C# 12, including nullable value types. However, nullable reference types aren’t available for aliasing.
permalinkConclusion
Expanded capabilities for aliasing in C# 12 has the potential to make your code cleaner and more readable for your teams.