Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Can you create instances named at runtime?

Can you create instances named at runtime?

Scheduled Pinned Locked Moved C#
algorithmsquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JDUK
    wrote on last edited by
    #1

    I want to create an instance of a class, the instance being named by the user at runtime. So i can put that instance in an arraylist and refer to it by name later (for removing and searching purposes). Is this possible?(& how?) or am i better off just cycling through the arraylist and searching for the significant identifier in each record. (in this case the Student Number) Thank you.

    D 1 Reply Last reply
    0
    • J JDUK

      I want to create an instance of a class, the instance being named by the user at runtime. So i can put that instance in an arraylist and refer to it by name later (for removing and searching purposes). Is this possible?(& how?) or am i better off just cycling through the arraylist and searching for the significant identifier in each record. (in this case the Student Number) Thank you.

      D Offline
      D Offline
      Daniel Turini
      wrote on last edited by
      #2

      See the sample for Hashtable on MSDN. It's what you need: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionshashtableclasstopic.asp[^] If the number of elements is very low (~<= 5), it's faster using an ArrayList, but usually the best thing is using a Hashtable. Yes, even I am blogging now!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups