CODEX
5 Ways To Drastically Shorten Your Code in C# 8.0
Save time and increase your development with these 5 techniques
The C#8.0 included extra features, officially released by Microsoft, which can streamline code. To use them correctly, I will demonstrate five methods to shorten your code drastically and compare them with the previous language constructs. Microsoft provides a detailed overview. [1]
The new version of C# offers various new features, allowing us to use some instructions for code that are more elegant than before. Pattern matching, for example, which has been further developed here, plays a major role.
1. Indexes
We begin by introducing the new functions for indexed access. The following example exhibits the indexed access to a string and an array with integer values, as it was usual until now:
The outputs are now the character M and the digit 2. C#8.0 offers an index operator that counts from the end of a string and is represented by the character ‘^’…