Do you import namespaces and shorten the references?

Loading last updated info...

You should import namespaces and shorten the references.

System.Text.StringBuilder myStringBuilder = new System.Text.StringBuilder();

❌ Figure: Figure: Bad code - Long reference to object name

using System.Text;
...
...
StringBuilder myStringBuilder = new StringBuilder();

✅ Figure: Figure: Good code - Import the namespace and remove the repeated System.Text reference

If you have ReSharper installed, you can let ReSharper take care of this for you:

Image

Figure: Right click and select "Reformat Code..."

Image

Figure: Make sure "Shorten references" is checked and click "Reformat"

Categories

Authors

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star