Re: A job for reflection? Or is there a better way?

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 04/27/04


Date: Tue, 27 Apr 2004 21:50:11 +0100

Gary Morris <gwmorris1@hotpop.com> wrote:
> > I don't see why you actually *do* need to do that. There's no need to
> > have the actual *variable* with the same name.
>
> OK, I don't actually have to have THE node name, I just want some way
> of creating each instance of the tabpage with a unique name. Since I've
> never had the need to do anything like this, I am looking for any option.

Objects don't necessarily *have* names. Usually I find when people want
to give objects names, they're really after some way of retrieving an
object by a string key later on. That's where hashtables come in
useful.
 
> > I suggest you create the tab page and just put it in a Hashtable, using
> > the node name as the key.
>
> Never used a hashtable, though I've seen many programs and code
> snippets that do use them. Maybe it's time to look into it....???

That would be a good idea. I suggest you familiarize yourself with
ArrayLists as well Hashtables before going much further - they're both
pretty fundamental to writing many .NET applications. If you look up
"collection classes" in the MSDN index, you'll see there's a tutorial
and a couple of samples available. I haven't gone through them myself,
but reading them (and/or a Collections chapter in a .NET book) would be
a good idea.

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Re: System.Collections
    ... will be shown in combobox1 start with "Wed" ... and will start with "Sat" while using Stack and other collections are ... Hashtables aren't ordered - they're just maps from keys to values. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: access hashtable within a hashtable
    ... Enumeration e = ht.keys; ... String key = null; ... are simple strings and values that represent "inner hashtables". ...
    (comp.lang.java.help)