Thread: Namespaces

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    329

    Namespaces

    Hi,

    I have a namespace containing many classes. I would like to access the classes dependent upon a user input variable. So for a namespace called foo, is there a way I can access it's classes with a variable? For example,

    foo.(variable)?

    I have tried having a variable string and trying foo.string but it doesn't work. Any suggestions?

    Thanks.

  2. #2
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    I'm certain you can do this using reflection. I'm also certain that there is a better class design for what you've described.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Why would namespace access be based on user input?

  4. #4
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Activator.CreateInstance Method (System)

    I believe you can specify assemblies to look in.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  5. #5
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    Sorry...I was talking complete rubbish. I was referring to method access through classes. Have done what I needed to now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. namespaces or static classes ?? you decide
    By Hussain Hani in forum C++ Programming
    Replies: 9
    Last Post: 07-11-2009, 11:20 AM
  2. need help wiht using classes...namespaces...
    By hockey97 in forum C++ Programming
    Replies: 9
    Last Post: 09-02-2008, 02:22 PM
  3. namespaces
    By Ancient Dragon in forum C++ Programming
    Replies: 6
    Last Post: 09-30-2005, 06:04 PM
  4. Namespaces
    By the pooper in forum C Programming
    Replies: 8
    Last Post: 01-21-2005, 09:06 AM
  5. namespaces
    By Mario in forum C++ Programming
    Replies: 3
    Last Post: 05-27-2002, 02:57 PM