Create List or Dictionary

S

shapper

Hello,

I need to create a List or a Dictionary with only to items:

Id = 1, Key = "Subscribe"

Id = 2, Key = "Unsubscribe"

Is it possible to create such a list or dictionary with only one code
line?

Thank You,

Miguel
 
V

vanderghast

Dictionary<string, int> toto = new Dictionary<int, string> { {
"Subscribe" , 1}, { "Unsubscribe", 2 } };


Vanderghast, Access MVP
 
T

Tony Johansson

vanderghast said:
Dictionary<string, int> toto = new Dictionary<int, string> { {
"Subscribe" , 1}, { "Unsubscribe", 2 } };


Vanderghast, Access MVP

This is probably are write mistake
Dictionary<string, int> toto = new Dictionary<int, string> { {
"Subscribe" , 1}, { "Unsubscribe", 2 } };

It should insted be written as

Dictionary said:
"Subscribe" , 1}, { "Unsubscribe", 2 } };

//Tony
 

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

Similar Threads

Extending Dictionary 2
Fill Dictionary in a Fluent Way 4
Dictionary 3
Dictionary 1
learning to code - dictionary question 8
Linq xml to dictionary help 3
Linq or dictionary 5
Generic Dictionary For Keys Only? 3

Top