Re: What type of object for this?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Brett,

I would use a class, and then have static fields as you do.

Additionally, I would have a type constructor which would initialize a
read-only dictionary which you expose, which would use reflection and cycle
through the fields exposed on the type. It would populate with name/values,
if you need that.

Either that, or I would pass the type around.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Brett Romero" <account@xxxxxxxxx> wrote in message
news:1144033861.096043.234420@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I need an object similar to a struct that allows me to write something
like this:

public struct TheFields
{
public static string Hand = "Hand";
public static string PersonID = "PersonID";
}

and reference the fields by name such as TheFields.Hand and get the
value "Hand". The above does all of this. However, I need the
ability to loop blindly through these fields (strings) and get their
values. This construct also needs to be passed in as a parameter to
an object, which will then loop through and get the string values.

I don't think an arraylist will work because I can say myarray.Hand.
I'd have to know what the index of hand is and even then, intellisense
will not do myarray[2].Hand. I need the intellisense to popout all of
the fields within this construct so I can go to the one I want.

Any ideas?

Thanks,
Brett



.



Relevant Pages

  • Re: Using ZeroMemory with strings?
    ... > I have a record which contains a number of floats and strings. ... Finalize has a complementary routine called Initialize. ... to call it after allocating memory for your record. ... necessary to call Initialize if you allocate the record with New, ...
    (borland.public.delphi.language.objectpascal)
  • Re: Modem initialization strings
    ... > modem initialization strings set through the registry. ... > is an enumerated sequence of strings that are used to initialize the ... > Jose Luis Balsera ...
    (microsoft.public.pocketpc.developer)
  • Re: C Static char* Array Question
    ... My question is how do I clean up the old value? ... I'm kind of assuming that the compiler is doing something with the ... Initialize the "DataThatCanChange" manually at the start of the ... any bigger than the old strings. ...
    (comp.lang.c)
  • Simple question with array of strings
    ... with C), it drives me crazy. ... the strings can be of different length and the array will be ... initialize the array, I preffer that it will take as little text space ...
    (comp.lang.cpp)
  • Re: typisierte und nicht typisierte DataSets
    ... Bei Strings geht ja immerhin ..ToString mit der Hilfe von Intellisense und ist noch erträglich. ... Armin ...
    (microsoft.public.de.german.entwickler.dotnet.vb)