![]() Public override IEnumerator GetEnumerator() IEnumerator> IEnumerable>.GetEnumerator() The three methods below return an enumerator for current collection. Set(( string)key, (T)collection.ToArray()) Gets or sets the item with the specified key. Removes the element with the specified key from the collection. void IDictionary.Add( object key, object value) Adds an object with the specified key to the colletion. Return key is string s & Keys.Contains(s) Determines whether the collection contains an element with the specified key. Indicates whether the collection contains a fixed number of items. public new bool IsReadOnly => base.IsReadOnly Indicates whether the collection is read-only. ICollection IDictionary.Values => Values Gets an collection containing the values. Public partial class NameValueCollection : Some methods and properties are implemented explicitly, that is, their use requires a prior casting to the appropriate interface's type. The last step is to implement the specified interfaces IDictionary and IEnumerable>. Gets both the key and the value of the current dictionary entry.ĭictionaryEntry IDictionaryEnumerator.Entry Gets the value of the current dictionary entry. Gets the key of the current dictionary entry. IEnumerator enumerator = ((IEnumerator) _enumerator) Returns the object of the collection corresponding // to the current position of the enumerator. Returns the element of the collection corresponding // to the current position of the enumerator. public Enumerator(NameValueCollection collection) private readonly IEnumerator> _enumerator ![]() private class Enumerator : IEnumerator>, IDictionaryEnumerator The enumerator that can enumerate all entries in the collection. The GetAllValues returns all values regardless of keys they are paired with, these method will be useful in the future. The GetKey and Get methods return the requested key and array of associated with key values. public void Set( string name, params T values) Set range of values (previous values will be removed). public void Add(NameValueCollection collection) The InvalidateCachedArrays method will reset the caches and will be called every time the data changes. Private fields will contain the cached data in specified arrays. The Class Definitionįor the first time, define the class and its members that contain keys and values. The interfaces IDictionary, IEnumerable> were implemented in the class as additional usability. The NameValueCollection collection is based on NameObjectCollectionBase - the base class for a collection of associated string keys and object values that contains base methods to access the values. The need to store objects in a collection in the original type attracted me to write a generic form of NameValueCollection as an alternative to NameValueCollection.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |