I just found the following code and don't know why it is done this way. Risk for conflict?
using DiffTreeNode = EPiServer.Enterprise.Diff.TreeNode;
And then in the class it is used as usual.
Why would you do something like this?
I just found the following code and don't know why it is done this way. Risk for conflict?
using DiffTreeNode = EPiServer.Enterprise.Diff.TreeNode;
And then in the class it is used as usual.
Why would you do something like this?
That's a
usingdirective (see here) rather than ausingstatement and very similar to something likeusing System.Text;.A
usingstatement allows you to automatically clean up stuff without mucking about withtry/catch/finallyblocks:The
usingdirective imports a namespace so that you don't have to explicitly use the namespace to prefix all the types within it. Your particular variant basically creates an alias for theEPiServer.Enterprise.Diff.TreeNodenamespace so you can simply refer to it asDiffTreeNodebeyond that point. In other words, after the directive:the following two statements are equivalent:
and I know which I'd prefer to type in.
Now you may be asking why, if the directive can let you use the types within a namespace on their own, why do we not just do:
My bet would be, though I'll wait for the likes of Jon Skeet to confirm or deny this :-), that it's to cover the case where you have two or more namespaces with identically named types. That would allow: