C# When did you read the using directive section on the top of each file?


csharp C# When did you read the using directive section on the top of each file? c #

csharp

I am wondering how many people actually read the ‘using directive’ on top of each C# file, like this:

1
2
3
4
5
6
7
8
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Drawing;
using System.Drawing.Imaging;
using System.Configuration;
using System.Drawing.Drawing2D;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Drawing;
using System.Drawing.Imaging;
using System.Configuration;
using System.Drawing.Drawing2D;

Let’s do a simple Poll:

  1. Always when I open a file
  2. Sometimes
  3. Never
  4. Sorry, I don’t know what using directive section means
  5. Everytime I do a code review!

My personal preference is to use region to hide them by default, like this:

1
2
3
4
5
6
7
8
9
10
#region using
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Drawing;
using System.Drawing.Imaging;
using System.Configuration;
using System.Drawing.Drawing2D;
#endregion 
#region using
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Drawing;
using System.Drawing.Imaging;
using System.Configuration;
using System.Drawing.Drawing2D;
#endregion 

Some might not like the entire world of #region/#endregion as it’s an incredibly annoying feature that allows developers to pretend their code is well written when in fact they are just hiding masses of ugly inefficient poor code.

Luckily, Resharper will be able to detect unused references and grey out lines to hint you a R# tidy up.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
290 words
Last Post: A Simple Msgbox Command Line Utility in Windows Batch
Next Post: R Tutorial - How to Connect to SteemSQL via RStudio?

The Permanent URL is: C# When did you read the using directive section on the top of each file?

Leave a Reply