Indexing using strings

  • Thread starter Thread starter K Viltersten
  • Start date Start date
K

K Viltersten

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

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

Does such type i want exist and what is its name?
 
K Viltersten said:
I'd like to use an array-like construction where i can
use strings as indicies. Example:

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

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

Dictionary<string,int>
 
Den 2008-06-03 23:46:43 skrev Jon Skeet said:
K Viltersten said:
I'd like to use an array-like construction where i can
use strings as indicies. Example:

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

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

Dictionary<string,int>

I knew there must be something! Thanks! I'll try it the first
thing in the morning.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top