基于Hashtable实现IDictionary<TKey, TValue>接口(部分成员即可)。
参考文档:
Hashtable: https://msdn.microsoft.com/en-us/library/system.collections.hashtable(v=vs.110).aspx
IDictionary<TKey, TValue>: https://msdn.microsoft.com/en-us/library/s4ys34ea(v=vs.110).aspx
基于Hashtable实现IDictionary<TKey, TValue>接口(部分成员即可)。
参考文档:
Hashtable: https://msdn.microsoft.com/en-us/library/system.collections.hashtable(v=vs.110).aspx
IDictionary<TKey, TValue>: https://msdn.microsoft.com/en-us/library/s4ys34ea(v=vs.110).aspx
| namespace HashTableDict | |
| { | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| public class Hashtable<TKey, TValue> : IDictionary<TKey, TValue> | |
| where TKey : class | |
| where TValue : class | |
| { | |
| private readonly Hashtable _ht = new Hashtable(); | |
| // 实现以下接口。 | |
| public int Count | |
| { | |
| get { throw new System.NotImplementedException(); } | |
| } | |
| public bool ContainsKey(TKey key) | |
| { | |
| throw new System.NotImplementedException(); | |
| } | |
| public void Add(TKey key, TValue value) | |
| { | |
| throw new System.NotImplementedException(); | |
| } | |
| public bool Remove(TKey key) | |
| { | |
| throw new System.NotImplementedException(); | |
| } | |
| public bool TryGetValue(TKey key, out TValue value) | |
| { | |
| throw new System.NotImplementedException(); | |
| } | |
| public TValue this[TKey key] | |
| { | |
| get { throw new System.NotImplementedException(); } | |
| set { throw new System.NotImplementedException(); } | |
| } | |
| public void Clear() | |
| { | |
| throw new System.NotImplementedException(); | |
| } | |
| /* 以下接口无需实现 */ | |
| public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() | |
| { | |
| throw new System.NotImplementedException(); | |
| } | |
| IEnumerator IEnumerable.GetEnumerator() | |
| { | |
| return GetEnumerator(); | |
| } | |
| public void Add(KeyValuePair<TKey, TValue> item) | |
| { | |
| throw new System.NotImplementedException(); | |
| } | |
| public bool Contains(KeyValuePair<TKey, TValue> item) | |
| { | |
| throw new System.NotImplementedException(); | |
| } | |
| public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) | |
| { | |
| throw new System.NotImplementedException(); | |
| } | |
| public bool Remove(KeyValuePair<TKey, TValue> item) | |
| { | |
| throw new System.NotImplementedException(); | |
| } | |
| public bool IsReadOnly | |
| { | |
| get { throw new System.NotImplementedException(); } | |
| } | |
| public ICollection<TKey> Keys | |
| { | |
| get { throw new System.NotImplementedException(); } | |
| } | |
| public ICollection<TValue> Values | |
| { | |
| get { throw new System.NotImplementedException(); } | |
| } | |
| } | |
| } |
Uh oh!
There was an error while loading. Please reload this page.