Remove All key value pair from Dictionary in IEnumerable - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IDictionary

Description

Remove All key value pair from Dictionary in IEnumerable

Demo Code


using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using System.Collections.Generic;
using System;/*from w  ww  . ja  va 2s .co  m*/

public class Main{
        [ObsoleteAttribute("This method is currently unused and excluded from code coverage. Should you decide to use it, please add a test.", true)]
        [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]  //used to hide from code coverage tools.
        public static void RemoveAll<K, V>(this Dictionary<K, V> dictionary, IEnumerable<K> keys)
        {
            foreach (var key in keys)
            {
                dictionary.Remove(key);
            }
        }
}

Related Tutorials