Silverlight 下创建Hashtable

Silverlight 下创建Hashtable,第1张

概述 Silverlight 下创建Hashtable using System;using System.Collections;using System.Collections.Generic;using System.Linq;namespace SFire.Framework{ /// <summary> /// Silverlight下使用的哈希表 /  Silverlight 下创建Hashtable

using System; System.Collections; System.Collections.Generic; System.linq;namespace SFire.Framework{    /// <summary>    /// Silverlight下使用的哈希表     创建者:sucsy     创建日期:2012-2-27    </summary>    public class DataHashtable : IDictionary    {        List<HashtableItem> table = null;        public DataHashtable()        {            this.table = new List<HashtableItem>();        }        voID Add(object key,object value)        {            if (this.Contains(key) == false)            {                table.Add                    (                        new HashtableItem()                        {                            Key = key,Value = value                        }                    );            }            else            {                this[key] = value;            }        }        voID Clear()        {            table.Clear();        }        bool Contains( key)        {            foreach (HashtableItem item in this.table)            {                if (item.Key!=null && item.Key.Equals(key)) return true;            }            ;        }         IDictionaryEnumerator GetEnumerator()        {            return (IDictionaryEnumerator).table.ToArray().GetEnumerator();        }        bool IsFixedSize        {            get { ; }        }         IsReadonly        {             ICollection Keys        {            this.table.Select(item => item.Key).ToArray(); }        }        voID Remove( key)        {            HashtableItem item = Find(key);            if (item != null) .table.Remove(item);        }        private HashtableItem Find( key)        {            HashtableItem find = ;            if (item.Key.Equals(key))                {                    find = item;                    break;                }            }            return find;        }         ICollection Values        {             item.Value).ToArray(); }        }        object this[ key]        {            get            {                HashtableItem item = Find(key);                 item.Value;                ;            }            setnull) item.Value =voID copyTo(Array array,255)">int index)        {            .table.copyTo((HashtableItem[])array,index);        }         Count        {            .table.Count; }        }         IsSynchronized        {             SyncRoot        {            ; }        }        IEnumerator IEnumerable.GetEnumerator()        {            .table.GetEnumerator();        }    }    #region 哈希表项     哈希表项     HashtableItem    {        <summary>         关键字        </summary>        object Key { get; ; }         源对象        object Value { ; }    }    #endregion}

总结

以上是内存溢出为你收集整理的Silverlight 下创建Hashtable全部内容,希望文章能够帮你解决Silverlight 下创建Hashtable所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1013372.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存