You can use:
var myList = new List<KeyValuePair<int, string>>(); myList.Add(new KeyValuePair<int, string>(1, "One"); foreach (var item in myList) { int i = item.Key; string s = item.Value; }
or if you are .NET Framework 4, you can use:
var myList = new List<Tuple<int, string>>(); myList.Add(Tuple.Create(1, "One")); foreach (var item in myList) { int i = item.Item1; string s = item.Item2; }
If the string or integer is unique to the set, you can use:
Dictionary<int, string> or Dictionary<string, int>
source share