locked
Using Statements Custom Class RRS feed

  • Question

  • Hi,

    I'm working on a project whereby I created a class which is inside a namespace DAR.Timetracking.Domain.Entities.Task

    I have to use the fully qualified namespace evry time I want to instantiating an object from that namespace. I cannot shorten it with the use of a using statement at the top.

    I think I need to decorate it with an attribute, but I cannot find which one.

    Can anyone help. The long, fully qualified paths are making my code more vebose than required.

    Tuesday, August 2, 2011 7:54 AM

Answers

  • perhaps you tried only

    Using DAR.Timetracking.Domain.Entities.Task;
    
    

    but you can use an alias:

    using DarTask = DAR.Timetracking.Domain.Entities.Task;
    
    




    please, mark this as answer if it is THE answer
    ----------------
    Diego Cattaruzza
    Microsoft MVP - Visual Basic: Development
    blog: http://community.visual-basic.it/Diego
    web site: http://www.visual-basic.it
    • Proposed as answer by RohitArora Wednesday, August 3, 2011 9:21 AM
    • Marked as answer by Dave Rogers99 Thursday, August 4, 2011 6:09 AM
    Tuesday, August 2, 2011 9:55 AM

All replies

  • perhaps you tried only

    Using DAR.Timetracking.Domain.Entities.Task;
    
    

    but you can use an alias:

    using DarTask = DAR.Timetracking.Domain.Entities.Task;
    
    




    please, mark this as answer if it is THE answer
    ----------------
    Diego Cattaruzza
    Microsoft MVP - Visual Basic: Development
    blog: http://community.visual-basic.it/Diego
    web site: http://www.visual-basic.it
    • Proposed as answer by RohitArora Wednesday, August 3, 2011 9:21 AM
    • Marked as answer by Dave Rogers99 Thursday, August 4, 2011 6:09 AM
    Tuesday, August 2, 2011 9:55 AM
  • Thanks Diego.

    That's a good suggestion, but I shy away from using aliases for maintenance reasons.

    I actually answered my question last night. In fact, the question was flawed.

    It was delegates and enums that I was referencing. And I realised that I do not need to include them in a class. They can exist within a namespace, and then the using statement for the namespace works as normal.

    Anyway, thanks again.

     

    Thursday, August 4, 2011 6:08 AM