IDictionary.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Diagnostics.CodeAnalysis;
  5. namespace System.Collections
  6. {
  7. // An IDictionary is a possibly unordered set of key-value pairs.
  8. // Keys can be any non-null object. Values can be any object.
  9. // You can look up a value in an IDictionary via the default indexed
  10. // property, Items.
  11. public interface IDictionary : ICollection
  12. {
  13. // Interfaces are not serializable
  14. // The Item property provides methods to read and edit entries
  15. // in the Dictionary.
  16. object? this[object key]
  17. {
  18. get;
  19. set;
  20. }
  21. // Returns a collections of the keys in this dictionary.
  22. ICollection Keys {get; }
  23. // Returns a collections of the values in this dictionary.
  24. ICollection Values { get; }
  25. // Returns whether this dictionary contains a particular key.
  26. bool Contains(object key);
  27. // Adds a key-value pair to the dictionary.
  28. void Add(object key, object? value);
  29. // Removes all pairs from the dictionary.
  30. void Clear();
  31. bool IsReadOnly { get; }
  32. bool IsFixedSize { get; }
  33. // Returns an IDictionaryEnumerator for this dictionary.
  34. new IDictionaryEnumerator GetEnumerator();
  35. // Removes a particular key from the dictionary.
  36. void Remove(object key);
  37. }
  38. }