Indexing using strings

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

    Indexing using strings

    I'd like to use an array-like construction where i can
    use strings as indicies. Example:

    ThatTypeIWant<i ntstuff = new ThatTypeIWant<i nt>();
    stuff["uno"] = 2;
    stuff["duo"] = 1;

    Does such type i want exist and what is its name?

    --
    Regards
    Konrad Viltersten
  • Jon Skeet [C# MVP]

    #2
    Re: Indexing using strings

    K Viltersten <tmp1@vilterste n.comwrote:
    I'd like to use an array-like construction where i can
    use strings as indicies. Example:
    >
    ThatTypeIWant<i ntstuff = new ThatTypeIWant<i nt>();
    stuff["uno"] = 2;
    stuff["duo"] = 1;
    >
    Does such type i want exist and what is its name?
    Dictionary<stri ng,int>

    --
    Jon Skeet - <skeet@pobox.co m>
    Web site: http://www.pobox.com/~skeet
    Blog: http://www.msmvps.com/jon.skeet
    C# in Depth: http://csharpindepth.com

    Comment

    • K Viltersten

      #3
      Re: Indexing using strings

      Den 2008-06-03 23:46:43 skrev Jon Skeet [C# MVP] <skeet@pobox.co m>:
      K Viltersten <tmp1@vilterste n.comwrote:
      >I'd like to use an array-like construction where i can
      >use strings as indicies. Example:
      >>
      >ThatTypeIWant< intstuff = new ThatTypeIWant<i nt>();
      >stuff["uno"] = 2;
      >stuff["duo"] = 1;
      >>
      >Does such type i want exist and what is its name?
      >
      Dictionary<stri ng,int>
      I knew there must be something! Thanks! I'll try it the first
      thing in the morning.


      --
      Regards
      Konrad Viltersten

      Comment

      Working...