自己写了个ASP.NET Web服务应用程序,里面有个参数是自己写的一个Dictionary,在运行的时候就报必须在 System.Collections.Generic.Dictionary`2+KeyCollection[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] 上实现默认访问器,因为它继承自 ICollection。
这个问题怎么解决,在线等答案public class MyDictionary<TKey, TValue>
    {
        public MyDictionary()
        {
            this.InternalDicktionary = new Dictionary<TKey, TValue>();
        }       
        protected Dictionary<TKey, TValue> InternalDicktionary { get; private set; }        public int Count { get { return this.InternalDicktionary.Count; } }        public Dictionary<TKey, TValue>.KeyCollection Keys { get { return this.InternalDicktionary.Keys; } }        public Dictionary<TKey, TValue>.ValueCollection Values { get { return this.InternalDicktionary.Values; } }        public TValue this[TKey key]
        {
            get { return this.InternalDicktionary[key]; }
            set { this.InternalDicktionary[key] = value; }
        }        public void Add(TKey key, TValue value)
        {
            this.InternalDicktionary.Add(key, value);
        }        public void Clear()
        {
            this.InternalDicktionary.Clear();
        }        public bool ContainsKey(TKey key)
        {
            return this.InternalDicktionary.ContainsKey(key);
        }        public bool ContainsValue(TValue value)
        {
            return this.InternalDicktionary.ContainsValue(value);
        }        public Dictionary<TKey, TValue>.Enumerator GetEnumerator()
        {
            return this.InternalDicktionary.GetEnumerator();
        }
        public bool Remove(TKey key)
        {
            return this.InternalDicktionary.Remove(key);
        }        public bool TryGetValue(TKey key, out TValue value)
        {
            return this.InternalDicktionary.TryGetValue(key, out value);
        }
    }
上面是我Dictionary的代码 

解决方案 »

  1.   

    但是这个webService写在一个网站下面的话是没有问题的完全可以用,但是单独写一个ASP.NET web服务应用程序就会报这个错,这又是为什么
      

  2.   

    不明白为什么要自己实现一个~
    直接继承Dictionary
    再添加一些自定义方法 不就可以了么~
      

  3.   

    如果直接继承Dictionary的话,那我这个类不也是继承了IDictionary吗,那样的话我还是不能用啊