Basically my question is about the following:
using myName = System.Web;
I recently came across some code which did something very similar to that above.
My question boils down to the following points:
I understand one of the benefits in which I have used this type of declaration:
using Security = System.Web.Security;
...
_roles = (SimpleRoleProvider)Security.Roles.Provider;
_membership = (SimpleMembershipProvider)Security.Membership.Provider;
As I had an entity named Membership I couldn't just do Membership.Provider without a conflict. So here the using declaration allows me to shortern the full use of System.Web.Security.Membership to just Security.Membership.Provider which feels nicer from an OCD point of view.
This is a using directive also called an namespace alias.
If you have two types of the same name but from different namespaces, you need to spell out the namespace every time you use that type. If it's a long namespace, you may want to give it an alias.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With