Simple SttrgDictionary Collection

N

Namshub

I simply whant to create a key pair, so i'm looking at the specialisted
string dictionary collection, but haven't got a clue how to implement the
two matching values in terms of properties for a control. Can anyone post
sample code on
how to get and set values into the Collection, and how to hook up I'm
assuming it will use the default collection editor or will I have to design
my own?

Cheers

Ric
 
L

Lonifasiko

Declaration:

private Dictionary<String, String> dictionary = new
Dictionary<string,string>();

See if key exists and set values:

if (!dictionary.ContainsKey(fleet.CurrentTrain.TrainId))
dictionary.Add("X"."111");
else
dictionary["X"] = 222;

Iteration with foreach:

string s = "edbcxed";
foreach (KeyValuePair<string, string> keyValue in dictionary)
s += keyValue.Value;

Hope it helps.
 

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

Top