Search code examples
c#.netc#-2.0csla

Directives and Assembly References


I've inherited an old .NET 2.0 C# system in work, currently sifting my way through an enormous code base. As I am a graduate I'm interested in why the existing developers did certain things, certain ways. One particular habit the previous developers had was, instead of importing the references at the top of the class like so -

using System.IO;

They did this continually throughout - (rather than importing the reference at the top).

System.IO.File.Exists();

Could anyone shed some light what the difference(s) is/are other than having to type more code? The system I'm working on is a business object orientated system (CSLA), and with no prior experience to this methodology, could someone recommend a good way to approach learning a system which I've inherited. I appreciate you can't see the system I've got but a bit of insight from someone experienced would be appreciated.

Regards.


Solution

  • It's just a style choice. Some people like to use the full names to know that local type names won't conflict with system types.

    using statements are just a way to help the compiler find the referenced types at compile time, there is no difference at runtime between;

    using System.IO;
    
    File.Exists();
    

    and

    System.IO.File.Exists();