Do you import namespaces and shorten the references?

Updated by Brady Stroud [SSW] 5 months ago. See history

123

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"

acknowledgements
related rules