Sunday, 22 January 2017

c# using statements placement










I am looking at a code base where the author (one I respect) consistently places using statements inside of the namespace, as opposed to above it. Is there some advantage (more efficient GC?) to doing so or is this just a code style preference?



Cheers,
Berryl



Answer



If you have multiple namespaces in the same file then you will be scoping usings only to the containing namespace instead of to all namespace in the entire file.



Also see (just found this good explanation) Should 'using' statements be inside or outside the namespace?


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...