I have a dictionary with several items in it:
public static Dictionary<string, string> vmDictionary = new Dictionary<string, string>();
And I have a method to add the items from within it to a listbox:
foreach (KeyValuePair<String, String> entry in MyApp.vmDictionary)
{
ListViewItem item = new ListViewItem();
item.SubItems.Add(entry.Value[0]);
item.SubItems.Add(entry.Value[1]);
selectVMListView.Items.Add(
}
Although I get the following error:
Error 2 Argument 1: cannot convert from ‘char’ to ‘string’
Relating to these lines:
item.SubItems.Add(entry.Value[0]);
item.SubItems.Add(entry.Value[1]);
entry.Value[0] and [1] should be string if I am not mistaken, but for some reason its complaining they are chars :S
entry.Valuereturns the value component of theKeyValuePair<,>, which in this case is astring, when you then use an index on thisstring, you are getting a char. I think what you mean to have is the following: