Skip to content

Instantly share code, notes, and snippets.

@MRdNk
Last active December 11, 2015 20:19
Show Gist options
  • Save MRdNk/4654896 to your computer and use it in GitHub Desktop.
Save MRdNk/4654896 to your computer and use it in GitHub Desktop.

C# List delegate

A delegate allows you perform an action on a list type, FindAll - returns a new list, based on the conditions you put into the delegate.

List<KeyValueBool<int, String>> list = disp.List.FindAll (delegate (KeyValueBool<int, string> kvb) {
  return kvb.Boolean == true;
});

KeyValueBool (class)

    public class KeyValueBool<TKey, TValue> {

        public TKey Key {
            get;
            set;
        }
        public TValue Value {
            get;
            set;
        }
        public Boolean Boolean {
            get;
            set;
        }

        public KeyValueBool (TKey key, TValue value, Boolean b) {
            this.Key = key;
            this.Value = value;
            this.Boolean = b;
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment