Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find and delete tuple from list of tuples in C# 4.0

I have created a list of tuples:

static List<Tuple<string, string>> Alt;

The user adds to this list:

Alt.Add(new Tuple<string, string>(tbAlt.Text, ""));

What is the best way to find a Tuple based on the first string (i.e. the tbAlt.Text ) and either delete it or modify the second string?

I am new to using Tuples and lists :)

Many thanks for any help!

like image 605
RHodgett Avatar asked Dec 21 '22 04:12

RHodgett


1 Answers

It appears the first string must be unique or you would not find a (singular)

Why are you using List<Tuple<string, string>>?

Why not Dictionary<string,string>?

Dictionary<TKey, TValue>.ContainsKey is very very fast.

Dictionary.ContainsKey

like image 63
paparazzo Avatar answered Dec 29 '22 19:12

paparazzo