当前位置: 首页>>代码示例>>C#>>正文


C# Hashtable.Clear方法代码示例

本文整理汇总了C#中System.Collections.Hashtable.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Hashtable.Clear方法的具体用法?C# Hashtable.Clear怎么用?C# Hashtable.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Hashtable的用法示例。


在下文中一共展示了Hashtable.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MaxSubStringWithUniqueChars

        private static string MaxSubStringWithUniqueChars(string str)
        {
            char[] cArr = str.ToCharArray();
            Hashtable h = new Hashtable();
            h.Clear();
            int n = cArr.Length;
            int begin = 0;
            int j = 0;
            string maxSub = "";
            for (int i = 0; i < n; ++i)
            {
                if (!h.Contains(cArr[i]))
                {
                    h.Add(cArr[i], true);
                    j++;

                }
                else
                {
                    int newSublen = j - begin;
                    if (maxSub.Length < newSublen)
                    {
                        maxSub = str.Substring(begin, j);

                    }
                    begin = i;
                    j = begin + 1;
                    h.Clear();
                }
            }
            return maxSub;
        }
开发者ID:msgsmg,项目名称:msggittest,代码行数:32,代码来源:Program.cs

示例2: TestClearBasic

        public void TestClearBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);
            Hashtable ht1 = null;
            string s1 = null;
            string s2 = null;

            int i = 0;
            ht1 = new Hashtable(); //default constructor
            ht1.Clear();

            Assert.Equal(0, ht1.Count);

            // add 100 key-val pairs
            ht1 = new Hashtable();

            for (i = 0; i < 100; i++)
            {
                sblMsg = new StringBuilder(99);
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg = new StringBuilder(99);
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                ht1.Add(s1, s2);
            }

            Assert.Equal(100, ht1.Count);
            ht1.Clear();

            Assert.Equal(0, ht1.Count);

            //[]we will make a token call for some important methods to make sure that this is indeed clear
            s1 = "key_0";
            Assert.False(ht1.ContainsKey(s1));

            s1 = "val_0";
            Assert.False(ht1.ContainsValue(s1));

            //[]repeated clears of the HT. Nothing should happen		

            for (i = 0; i < 100; i++)
            {
                ht1.Clear();

                Assert.Equal(0, ht1.Count);
            }
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:52,代码来源:ClearTests.cs

示例3: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                acceptGuid = Request.Params["AcceptGuid"];
                string adPGuid, clientPGuid, adClass = string.Empty;
                if (!string.IsNullOrEmpty(acceptGuid))
                {
                    Hashtable hs = new Hashtable();
                    hs.Add("AcceptGuid", acceptGuid);
                    HD.Model.AcceptForm accept = HD.Model.AcceptForm.Instance.GetModelById(hs);
                    accept.SetWebControls(this.Page);
                    PostTime.Text = Convert.ToDateTime(accept.PostTime).ToString("yyyy-MM-dd");

                    adPGuid = accept.ADGuid;
                    hs.Clear();
                    hs.Add("ADPGuid", adPGuid);
                    HD.Model.AD ad = HD.Model.AD.Instance.GetModelById(hs);
                    ad.SetWebControls(this.Page);
                    adClass = ad.ADArea;
                    adAreaId = ad.ADArea;
                    StartTime.Text = Convert.ToDateTime(ad.StartTime).ToString("yyyy-MM-dd");
                    EndTime.Text = Convert.ToDateTime(ad.EndTime).ToString("yyyy-MM-dd");
                    if (!string.IsNullOrEmpty(adAreaId))
                    {
                        ChooseCount = (adAreaId.Split(',').Length - 2).ToString();
                    }
                    clientPGuid = accept.ClientGuid;
                    hs.Clear();
                    hs.Add("ClientPGuid", clientPGuid);
                    HD.Model.Client client = HD.Model.Client.Instance.GetModelById(hs);
                    client.SetWebControls(this.Page);

                    DataTable dt2 = HD.Framework.DataAccess.DataFactory.GetInstance().ExecuteTable("select wzrb_Class.ID, wzrb_Class.ClassName, (select COUNT(*) from wzrb_Terminal where ClassID=wzrb_Class.ID and Status=1)  as rcount from wzrb_Class");
                    rptClass.DataSource = dt2;
                    rptClass.DataBind();

                    DataTable dttype = HD.Framework.DataAccess.DataFactory.GetInstance().ExecuteTable("select * from wzrb_Publish where ADGuid='" + ad.ADPGuid + "'");
                    publishType = "<table id=\"CheckBoxList2\">";
                    for (int k = 0; k < dttype.Rows.Count; k++)
                    {
                        publishType += "<tr><td>" + GetPublishName(dttype.Rows[k]["PublishType"].ToString());
                        publishType += " -- 数量:" + dttype.Rows[k]["PublishQuantity"];
                        publishType += "</td></tr>";
                    }
                    publishType += "</table>";
                }
            }
        }
开发者ID:flxc11,项目名称:TerminalMS,代码行数:49,代码来源:UserAcceptDetail.aspx.cs

示例4: TestCtorDictionarySingle

        public void TestCtorDictionarySingle()
        {
            // No exception
            var hash = new Hashtable(new Hashtable(), 1f);
            // No exception
            hash = new Hashtable(new Hashtable(new Hashtable(new Hashtable(new Hashtable(new Hashtable()), 1f), 1f), 1f), 1f);

            // []test to see if elements really get copied from old dictionary to new hashtable
            Hashtable tempHash = new Hashtable();
            // this for assumes that MinValue is a negative!
            for (long i = long.MinValue; i < long.MinValue + 100; i++)
            {
                tempHash.Add(i, i);
            }

            hash = new Hashtable(tempHash, 1f);

            // make sure that new hashtable has the elements in it that old hashtable had
            for (long i = long.MinValue; i < long.MinValue + 100; i++)
            {
                Assert.True(hash.ContainsKey(i));
                Assert.True(hash.ContainsValue(i));
            }

            //[]make sure that there are no connections with the old and the new hashtable
            tempHash.Clear();
            for (long i = long.MinValue; i < long.MinValue + 100; i++)
            {
                Assert.True(hash.ContainsKey(i));
                Assert.True(hash.ContainsValue(i));
            }
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:32,代码来源:CtorTests.cs

示例5: GpsCarFilterToHashTable

 public Hashtable GpsCarFilterToHashTable(int int_0)
 {
     SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@workId", int_0) };
     DataTable table = new SqlDataAccess().getDataBySP("WebGpsClient_GetCarFilter", parameterArray);
     Hashtable hashtable = new Hashtable();
     if (hashtable.Count > 0)
     {
         hashtable.Clear();
     }
     CarFilterInfo info = null;
     foreach (DataRow row in table.Rows)
     {
         if (row["simNum"] != DBNull.Value)
         {
             info = new CarFilterInfo {
                 SimNum = Convert.ToString(row["simNum"]),
                 CarInfoData = CarDataInfoBuffer.GetDataCarInfoBySimNum(info.SimNum)
             };
             if (info.CarInfoData != null)
             {
                 info.PosReadTime = info.CarInfoData.IsNewPosTime;
                 info.PicReadTime = info.CarInfoData.IsNewPicTime;
                 hashtable.Add(info.SimNum, info);
             }
         }
     }
     return hashtable;
 }
开发者ID:lexzh,项目名称:Myproject,代码行数:28,代码来源:CarFilter.cs

示例6: GetMissingDefinitions

 public Hashtable GetMissingDefinitions()
 {
     MissingDefinition definition;
     Hashtable hashtable = new Hashtable();
     try
     {
         if (!this.TableExists("KindOfMissing"))
         {
             throw new Exception();
         }
         DataTable table1 = this._data.Tables["KindOfMissing"];
         foreach (DataRow row in this._data.Tables["KindOfMissing"].Rows)
         {
             int key = Convert.ToInt32((string)row["Key"]);
             string text = (string)row["Text"];
             bool capturable = ((string)row["Capturable"]).ToUpper() != "NO";
             definition = new MissingDefinition(key, text, capturable);
             key = definition.Key;
             if (!hashtable.ContainsKey(key))
             {
                 hashtable.Add(key, definition);
             }
         }
         return hashtable;
     }
     catch
     {
         hashtable.Clear();
         definition = new MissingDefinition(0, "Missing", false);
         hashtable.Add(0, definition);
         definition = new MissingDefinition(1, "Available", true);
         hashtable.Add(1, definition);
     }
     return hashtable;
 }
开发者ID:coppermine,项目名称:LScanFramework,代码行数:35,代码来源:XmlConfigFile.cs

示例7: Main

        static void Main(string[] args)
        {
            Hashtable seen = new Hashtable();
            int max = 0;
            int maxD = 0;
            for (int i = 1; i < 1000; i++) {
                seen.Clear();
                int r = 1;
                int count = 0;
                int result = 0;
                bool found = false;
                while(!found) {
                    if (seen.ContainsKey(r)) {
                        found = true;
                        result = count - (int)seen[r];
                    } else {
                        seen.Add(r, count);
                        r = r % i;
                        if (r == 0) {
                            found = true;
                        } else {
                            r = r * 10;
                        }
                    }
                    count++;
                }
                if(max < result) {
                    max = result;
                    maxD = i;
                }
            }

            Console.WriteLine(maxD + " " + max);
            Console.ReadLine();
        }
开发者ID:ThRM,项目名称:BackOnTheWeb,代码行数:35,代码来源:Program.cs

示例8: Execute

        public static Task<Hashtable> Execute(string method, Hashtable parms,ref Int64 requestid )
        {
            string strParams="";
            IEnumerator enu = parms.Keys.GetEnumerator();
            while (enu.MoveNext())
            {
                string parm = enu.Current.ToString() + "=" + Convert.ToString(parms[enu.Current.ToString()]);
                strParams = strParams + parm + "&";
            }

            strParams = strParams + "requestid=" + requestid.ToString()+"&";

             var result = Task<Hashtable>.Factory.StartNew(() =>
            {
                Hashtable ReturnData = new Hashtable();
                try
                {
                    Encoding encoding = Encoding.UTF8;
                    string strurl = strBaseUrl + strExecutePage;

                    string strJason = PostHttpResponse.GetStream(PostHttpResponse.CreatePostHttpResponseJson(strurl, "", "method=" + method + "&"+strParams + "clienttype=mobile", 300*1000, "", encoding, "", ref m_CookieContainer, true), encoding);
                    ReturnData = (Hashtable)MiniUiAppCode.JSON.Decode(strJason);

                }
                catch (Exception ex)
                {

                    ReturnData.Clear();
                    ReturnData.Add("error", "-1");
                    ReturnData.Add("message", "client error:" + ex.Message.ToString());
                }
                return ReturnData;
            });
            return result;
        }
开发者ID:hantao2015,项目名称:FinisarWebDll,代码行数:35,代码来源:RealsunClientNet.cs

示例9: Main_7_9_5

        //Main_7_9_5
        public static void Main_7_9_5()
        {
            Hashtable ht = new Hashtable();

            //��Ӽ���Ԫ��
            ht.Add("Name", "��");
            ht.Add("Age", 27);
            ht.Add("Degree", "˶ʿ");

            //�Լ�ֵ���Ҽ���
            Console.WriteLine("{0}��������{1}", ht["Name"], ht["Age"]);

            //���ϱ���
            foreach (DictionaryEntry de in ht)
            {
                Console.WriteLine("{0}--{1}", de.Key.ToString(), de.Value.ToString());
            }

            //ɾ������Ԫ��
            ht.Remove("Age");

            //��������
            ArrayList als = new ArrayList(ht.Keys);
            als.Sort();
            foreach (string key in als)
            {
                Console.WriteLine("{0}--{1}", key, ht[key].ToString());
            }

            //�������
            ht.Clear();
        }
开发者ID:anytao,项目名称:insidenet,代码行数:33,代码来源:HashtableEx.cs

示例10: Initialize

        public void Initialize(Framework.Interfaces.ICore core)
        {
            _core = core;
            _availableWaypoints = new Hashtable();

            try
            {
                _dbcon = new Utils.DBConComSqlite(Path.Combine(core.PluginDataPath,"gcvote.db3"));

                object o = _dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='votes'");
                if (o == null || o.GetType() == typeof(DBNull))
                {
                    _dbcon.ExecuteNonQuery("create table 'votes' (Waypoint text, VoteMedian float, VoteAvg float, VoteCnt integer, VoteUser double)");
                    _dbcon.ExecuteNonQuery("create unique index idx_votess on votes (Waypoint)");
                }

                DbDataReader dr = _dbcon.ExecuteReader("select Waypoint from votes");
                while (dr.Read())
                {
                    _availableWaypoints.Add(dr[0], true);
                }
            }
            catch
            {
                _dbcon = null;
                _availableWaypoints.Clear();
            }
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:28,代码来源:Repository.cs

示例11: GetSiteDetails

       public Hashtable GetSiteDetails()
       {
           Hashtable _SiteDetails = new Hashtable();
           try
           {
               Logger.Debug("Refreshing Site details:GetSiteDetails");
               ISingleResult<rsp_EventTransmitter_GetSiteDetailsResult> ResultSet = _ExchangeContext.rsp_EventTransmitter_GetSiteDetails();
              
               foreach (rsp_EventTransmitter_GetSiteDetailsResult oInst in ResultSet)
               {
                   _SiteDetails.Add("Area", oInst.sub_company_area_name);
                   _SiteDetails.Add("Company", oInst.Company_name);
                   _SiteDetails.Add("District", oInst.sub_company_District_Name);
                   _SiteDetails.Add("Region", oInst.Sub_Company_Region_Name);
                   _SiteDetails.Add("Sub_Company", oInst.sub_company_Name);
               }

           }
           catch (Exception Ex)
           {
               Logger.Error("DataAdapter", "GetSiteDetails()", Ex);
               _SiteDetails.Clear();
               _SiteDetails.Add("Area", string.Empty);
               _SiteDetails.Add("Company", string.Empty);
               _SiteDetails.Add("District", string.Empty);
               _SiteDetails.Add("Region", string.Empty);
               _SiteDetails.Add("Sub_Company", string.Empty);
           }
           return _SiteDetails;
       }
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:30,代码来源:DataAdapter.cs

示例12: login

        public bool login(string username, string password, string catpcha)
        {
            HttpRequest request = HttpRequest.getInstance();
            string result = "";
            string url = "";
            Hashtable param = new Hashtable();

            url = "http://192.168.0.12:8080/ibts/j_spring_security_check";
            param.Clear();
            param.Add("j_organization_code", "10000201");
            param.Add("j_username", username);
            param.Add("j_password", password);
            param.Add("j_verifycode", catpcha);
            result = request.doPost(url, param);

            //url = "http://192.168.0.12:8080/ibts/user_authSuccess.action";
            //param.Clear();
            //result = request.doPost(url, param);

            //url = "http://192.168.0.12:8080/ibts/main.action";
            //param.Clear();
            //result = request.doPost(url, param);

            return true;
        }
开发者ID:JasonDevStudio,项目名称:IBTS_WORD,代码行数:25,代码来源:PostMessage.cs

示例13: GetInputValues

        /// <summary>
        /// 輸入變數兜成HashTable
        /// </summary>
        /// <param name="ParameterList">變數集</param>
        /// <returns>回傳HashTable</returns>
        private Hashtable GetInputValues(ArrayList ParameterList)
        {
            #region

            Hashtable htTemp = new Hashtable();
            htTemp.Clear();

            htTemp.Add("ChanFrom", ParameterList[0].ToString().Trim() == "" ? null : ParameterList[0].ToString().Trim());
            htTemp.Add("ChanTo", ParameterList[1].ToString().Trim() == "" ? null : ParameterList[1].ToString().Trim());

            htTemp.Add("DateFrom", ParameterList[2].ToString().Trim() == "" ? null : ParameterList[2].ToString().Trim());
            htTemp.Add("DateTo", ParameterList[3].ToString().Trim() == "" ? null : ParameterList[3].ToString().Trim());
            htTemp.Add("RankCode", ParameterList[4].ToString().Trim() == "" ? null : ParameterList[4].ToString().Trim());
            htTemp.Add("UserID", ParameterList[5].ToString());
            htTemp.Add("ProcNo", ParameterList[6].ToString());
            Int32 iTopRownum;
            Int32.TryParse(ParameterList[7].ToString(), out iTopRownum);
            htTemp.Add("TopRownum", iTopRownum);

            htTemp.Add("StoreFrom", ParameterList[8].ToString().Trim() == "" ? null : ParameterList[8].ToString().Trim());
            htTemp.Add("StoreTo", ParameterList[9].ToString().Trim() == "" ? null : ParameterList[9].ToString().Trim());
            htTemp.Add("RootNo", ParameterList[10].ToString().Trim() == "" ? null : ParameterList[10].ToString().Trim());
            htTemp.Add("PMAFrom", ParameterList[11].ToString().Trim() == "" ? null : ParameterList[11].ToString().Trim());
            htTemp.Add("PMATo", ParameterList[12].ToString().Trim() == "" ? null : ParameterList[12].ToString().Trim());
            htTemp.Add("PatternFrom", ParameterList[13].ToString().Trim() == "" ? null : ParameterList[13].ToString().Trim());
            htTemp.Add("PatternTo", ParameterList[14].ToString().Trim() == "" ? null : ParameterList[14].ToString().Trim());

            return htTemp;
            
            #endregion
        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:36,代码来源:ALO03.cs

示例14: ButtonAdd2Cart_Click

        /// <summary>
        /// "放入购物车"按钮单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ButtonAdd2Cart_Click(object sender, System.EventArgs e)
        {
            if (Session["user_id"] == null)
                Page.Response.Redirect("Login.aspx?in=1");

            Cart cart = new Cart();
            Hashtable ht = new Hashtable();
            ArrayList selectedBooks = this.GetSelected();

            //如果用户没有选择,就单击该按钮,则给出警告
            if (selectedBooks.Count == 0)
            {
                Response.Write("<Script Language=JavaScript>alert('请选择图书!');</Script>");
                return;
            }

            //循环将选择的图书加入到购物篮中
            foreach (int bookId in selectedBooks)
            {
                ht.Clear();
                ht.Add("UserId", Session["user_id"].ToString());
                ht.Add("BookId", bookId);
                ht.Add("Amount", TextBoxAmount.Text.Trim());
                cart.Add(ht);
            }
            Response.Redirect("CartView.aspx");
        }
开发者ID:JohnToCoder,项目名称:MyBookShop_1,代码行数:32,代码来源:BookList.aspx.cs

示例15: Login

        public static Task<Hashtable>  Login(string user, string upass)
        {
            var result = Task<Hashtable>.Factory.StartNew(() =>
            {
                Hashtable loginReturnData = new Hashtable() ;
                try
                {
                    Encoding encoding = Encoding.UTF8;
                    string strurl = strBaseUrl + strLoginPage;

                    string strJason = PostHttpResponse.GetStream(PostHttpResponse.CreatePostHttpResponseJson(strurl, "", "user="+user+"&upass="+upass+"&clienttype=mobile", null, "", encoding, "", ref m_CookieContainer, true), encoding);
                    loginReturnData = (Hashtable)MiniUiAppCode.JSON.Decode(strJason);

                }
                catch (Exception ex)
                {

                    loginReturnData.Clear();
                    loginReturnData.Add("error", "-1");
                    loginReturnData.Add("message", "client error:"+ex.Message.ToString());
                }
                return loginReturnData;
            });
            return result;

        }
开发者ID:hantao2015,项目名称:MahApps.Metro-master,代码行数:26,代码来源:RealsunClientNet.cs


注:本文中的System.Collections.Hashtable.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。