System.Collections.Hashtable.ContainsKey C# (CSharp) Метод

ContainsKey() публичный Метод

public ContainsKey ( Object key ) : bool
key Object
Результат bool
        public virtual bool ContainsKey(Object key)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
            }
            Contract.EndContractBlock();

            uint seed;
            uint incr;
            // Take a snapshot of buckets, in case another thread resizes table
            bucket[] lbuckets = _buckets;
            uint hashcode = InitHash(key, lbuckets.Length, out seed, out incr);
            int ntry = 0;

            bucket b;
            int bucketNumber = (int)(seed % (uint)lbuckets.Length);
            do
            {
                b = lbuckets[bucketNumber];
                if (b.key == null)
                {
                    return false;
                }
                if (((b.hash_coll & 0x7FFFFFFF) == hashcode) &&
                    KeyEquals(b.key, key))
                    return true;
                bucketNumber = (int)(((long)bucketNumber + incr) % (uint)lbuckets.Length);
            } while (b.hash_coll < 0 && ++ntry < lbuckets.Length);
            return false;
        }

Usage Example

Пример #1
0
        public FileTag(Hashtable options)
        {
            StatusEvent.FireStatusError(this, statusEvent, Globalisation.GetString(""));
            if (options.ContainsKey("Db"))
            {
                this.Db = (MyDatabase)options["Db"];
            }

            if (options.ContainsKey("Form"))
            {
                this.Form = (Form1)options["Form"];
            }

            if (options.ContainsKey("listview"))
            {
                this.ListView = (ListView)options["listview"];
                this.ListView.MouseDown += new MouseEventHandler(mouseDown_ListView);

                this.ListView.OwnerDraw = true;
                this.ListView.DrawItem += new DrawListViewItemEventHandler(ListView_DrawItem);
            }

            if (options.ContainsKey("infopanel"))
            {
                this.Infopanel = (RichTextBox)options["infopanel"];
            }

            if (options.ContainsKey("GridFile"))
            {
                this.GridFile = (GridFile)options["GridFile"];
                this.GridFileListView = this.GridFile.GetListView();
                //this.GridFileListView.MouseDown += new MouseEventHandler(mouseDown_LoadTag);
                this.GridFileListView.SelectedIndexChanged += new System.EventHandler(this.center_listview_SelectedIndexChanged);
            }
        }
All Usage Examples Of System.Collections.Hashtable::ContainsKey