Array with string index

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    #1

    Array with string index

    Hi

    Is there a way to create an array of strings of subscript of type index too?
    Like;

    x("Element A")="Value for element A"

    Thanks

    Regards


  • Ken Tucker [MVP]

    #2
    Re: Array with string index

    Hi,

    Take a look at the hash table.
    http://msdn.microsoft.com/library/de...classtopic.asp


    Ken
    ----------------
    "John" <john@nospam.in fovis.co.uk> wrote in message
    news:esoWmjgMEH A.1188@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Hi
    >
    > Is there a way to create an array of strings of subscript of type index
    > too?
    > Like;
    >
    > x("Element A")="Value for element A"
    >
    > Thanks
    >
    > Regards
    >
    >[/color]


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Array with string index

      * "John" <john@nospam.in fovis.co.uk> scripsit:[color=blue]
      > Is there a way to create an array of strings of subscript of type index too?[/color]

      'Hashtable' class.

      --
      Herfried K. Wagner [MVP]
      <URL:http://dotnet.mvps.org/>

      Comment

      • Armin Zingler

        #4
        Re: Array with string index

        "John" <john@nospam.in fovis.co.uk> schrieb[color=blue]
        >
        > Is there a way to create an array of strings of subscript of type
        > index too? Like;
        >
        > x("Element A")="Value for element A"[/color]

        Hashtable


        --
        Armin

        How to quote and why:



        Comment

        • Tom Shelton

          #5
          Re: Array with string index

          In article <esoWmjgMEHA.11 88@TK2MSFTNGP12 .phx.gbl>, John wrote:[color=blue]
          > Hi
          >
          > Is there a way to create an array of strings of subscript of type index too?
          > Like;
          >
          > x("Element A")="Value for element A"
          >
          > Thanks
          >
          > Regards[/color]

          Others have suggested System.Collecti ons.Hashtable, but I would like to
          throw out, System.Collecti ons.Specialized .StringDictiona ry.

          --
          Tom Shelton [MVP]

          Comment

          • John

            #6
            Re: Array with string index

            What are the advantages of StringDictionar y over hashtable?

            Thanks

            Regards


            "Tom Shelton" <tom@mtogden.co m> wrote in message
            news:eg9t3qgMEH A.2736@TK2MSFTN GP11.phx.gbl...[color=blue]
            > In article <esoWmjgMEHA.11 88@TK2MSFTNGP12 .phx.gbl>, John wrote:[color=green]
            > > Hi
            > >
            > > Is there a way to create an array of strings of subscript of type index[/color][/color]
            too?[color=blue][color=green]
            > > Like;
            > >
            > > x("Element A")="Value for element A"
            > >
            > > Thanks
            > >
            > > Regards[/color]
            >
            > Others have suggested System.Collecti ons.Hashtable, but I would like to
            > throw out, System.Collecti ons.Specialized .StringDictiona ry.
            >
            > --
            > Tom Shelton [MVP][/color]


            Comment

            • Tom Shelton

              #7
              Re: Array with string index

              In article <O03PBugMEHA.80 8@tk2msftngp13. phx.gbl>, John wrote:[color=blue]
              > What are the advantages of StringDictionar y over hashtable?
              >
              > Thanks
              >
              > Regards[/color]

              It's typesafe. It only takes strings as keys and only takes strings as
              values. Hashtable takes object, so you have to do a lot of casting :)

              --
              Tom Shelton [MVP]

              Comment

              • Jay B. Harlow [MVP - Outlook]

                #8
                Re: Array with string index

                John,
                In addition to HashTable & StringDictionar y, there are:

                System.Collecti ons.DictionaryB ase - for creating your own type safe
                dictionaries (hash tables)

                System.Collecti ons.Specialized .NameObjectColl ectionBase - for creating your
                own type safe that are keyed by Strings & indexed.

                System.Collecti ons.Specialized .NameValueColle ction which is similar to
                StringDictionar y, however also supports being indexed by an integer...

                Basically check out the various collections in both System.Collecti ons &
                System.Collecti ons.Specialized .

                Hope this helps
                Jay

                "John" <john@nospam.in fovis.co.uk> wrote in message
                news:esoWmjgMEH A.1188@TK2MSFTN GP12.phx.gbl...[color=blue]
                > Hi
                >
                > Is there a way to create an array of strings of subscript of type index[/color]
                too?[color=blue]
                > Like;
                >
                > x("Element A")="Value for element A"
                >
                > Thanks
                >
                > Regards
                >
                >[/color]


                Comment

                Working...