Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8982095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:30:08+00:00 2026-06-15T20:30:08+00:00

I just found the following code and don’t know why it is done this

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:30:10+00:00Added an answer on June 15, 2026 at 8:30 pm

    That’s a using directive (see here) rather than a using statement and very similar to something like using System.Text;.


    A using statement allows you to automatically clean up stuff without mucking about with try/catch/finally blocks:

    using (Sometype xyzzy = new SomeType()) {
        // Do whatever with xyzzy
    }
    // xyzzy is gone, pining for the fjords.
    

    The using directive 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 the EPiServer.Enterprise.Diff.TreeNode namespace so you can simply refer to it as DiffTreeNode beyond that point. In other words, after the directive:

    using DiffTreeNode = EPiServer.Enterprise.Diff.TreeNode;
    

    the following two statements are equivalent:

    EPiServer.Enterprise.Diff.TreeNode.SomeType xyzzy =
        new EPiServer.Enterprise.Diff.TreeNode.SomeType();
    DiffTreeNode.SomeType xyzzy = new DiffTreeNode.SomeType();
    

    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:

    using EPiServer.Enterprise.Diff.TreeNode;
    SomeType xyzzy = new SomeType();
    

    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:

    using Bt = Trees.BinaryTree;       // Has Tree type.
    using Rbt = Trees.RedBlackTree;    // Annoyingly, also has Tree type.
    Tree t = new Tree();               // Is this binary or redbalck?
    Bt.Tree t1 = new Bt.Tree();        // Definite type.
    Rbt.Tree t2 = new Rbt.Tree();      // Ditto.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm debugging some code and have found the following code snippet and just don't
I just tried disassembling some shellcode using disasm and I found the following statement
I found the following code in SO. Does this really work? String xml =
In the following code I'm using 3 foreach statements. I'm just looking to populate
Edit: Just found out this is a chrome problem, the code works fine in
After hours of Googling on this subject matter, I found the following code snippet
I just found out this weird behavior, is this a bug or what am
I just found out about superfish and currently using it on an asp.net. The
I'm using the following code to scrape an eBay listing using the scrAPI gem:
I found the following code on here that I think does what I want,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.