I Only know one key from dictionary and I want to Select all other key that are present.
I don't want to remove the KeyValue pair that I know but want to select rest.
For example, I have:
Key:Health
Value: 123
Key:Vision
Value: 345
Key:Dental
value:567
and I know that Health will be there. So I want to select all other Keyvalue pairs except Key:Health
Could any one suggest a C# code to implement this ?
var allKeyValuesButHealth = dict.Where(kv => kv.Key != "Health");
Since this is a deferred executed LINQ query it's a good idea to materialize it with ToList, ToArray or even ToDictionary if you want to use it multiple times.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With