locked
Creating and Using a "Keyed" Array RRS feed

  • Question

  • User-748031297 posted

    I am coding a module in which I would like to create a string array that can be indexed by a string value rather than an integer.  For instance, I would like to be able to code:

    MyArray("054CAN")="Something"

    and then later be able to reference the array values using:

    MyString=MyArray("054CAN")

     

    How can I accomplish this?  Thanks for the help!

    Friday, November 16, 2012 1:33 PM

Answers

  • User551462331 posted

    you are actually looking for dictionary object...

    check this

    http://www.dotnetperls.com/dictionary

    hope this helps...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 16, 2012 1:41 PM

All replies

  • User551462331 posted

    you are actually looking for dictionary object...

    check this

    http://www.dotnetperls.com/dictionary

    hope this helps...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 16, 2012 1:41 PM
  • User1211441112 posted

    Use Dictionary<TKey, TValue>

    var dict = new Dictionary<string, string>();

    dict["key_name"] = "value1";

    Refer this

    http://www.dotnetperls.com/dictionary

    Friday, November 16, 2012 1:43 PM