Reputation: 883
I have the one Dictionary variable and Listbox.
Dictionary variable have the following values,
first
Second
ListBox can have
first
Second
Third
Expected Output is : Third
Now I need the get the value from Listbox which is not available in the Dictionary?How to Compare the Listbox with Dictionary Value?
Upvotes: 0
Views: 97
Reputation: 768
class Program
{
static void Main(string[] args)
{
List<string> list = new List<string>();
list.Add("First");
list.Add("second");
list.Add("third");
Dictionary<int, string> dictionary = new Dictionary<int, string>();
dictionary.Add( 1,"First");
dictionary.Add(2,"second");
foreach (var li in list)
{
if (!dictionary.ContainsValue(li))
{
Console.WriteLine(li);
}
}
Console.ReadLine();
}
}
Upvotes: 4