I need to convert an integer array to a list of KeyValuePair where the string can be an empty string. What would be an efficient and elegant way to do this?
So from this:
int[] ints = new int[] { 1, 2, 3 };
to this:
List<KeyValuePair<int, string>> pairs = new List<KeyValuePair<int, string>>();
pairs.Add(new KeyValuePair<int, string>(1, ""));
pairs.Add(new KeyValuePair<int, string>(2, ""));
pairs.Add(new KeyValuePair<int, string>(3, ""));
Obviously there are many ways to do this, starting from a for loop but I'm looking for preferably a single line of code, perhaps a linq statement if possible.