Results 1 to 7 of 7

Thread: Name spaces!!!

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Name spaces!!!

    Well, I just need a little suggestion. Lets say I'm creating a name space "tools". I want to have sections in tools, like "tools.file.{other functions here}" . I was just wondering what's a good way to add categories to my name space? should I make them all classes, modules, or what?

    something like this:
    Namespace Tools
    Class File
    ......some functions here.......
    End Class

    Class Graphics
    ........some functions here.......
    End Class
    End Namespace

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    the way you state is probably the best usage for a Namespace.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    tnx alot, I just didnt know the correct way

  4. #4
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    I'm just trying these namespaces, just one question, how do you call them in the main program?
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  5. #5
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Imports namespacename.classname
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  6. #6

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    I dunno if this is a good thing to do, but I ended up declaring the functions in my namespace's class as SHARED, so I would be able to use them without declaring an object from that class.
    like this:
    VB Code:
    1. Namespace Tools
    2.        Class File
    3.                 Shared Function ......    
    4.                 Shared Function ......    
    5.                 Shared Function ......    
    6.        End Class
    7.  
    8.        Class Path
    9.                 Shared Function ......    
    10.                 Shared Function ......    
    11.                 Shared Function ......    
    12.         End Class
    13. End Namespace

    Is it a bad idea to declared all the functions as shared?

  7. #7
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Well I really depends. the Shared attribute is mostly used for sharing data for the procedure or varaiable across other instances of the class. So if thats what you need it for then i guess there is no problem. Otherwise if you just want all the classes to share a procedure in a single instance, it would probably be best to put them in a public module
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width