• 2009年12月小记(Split,netstat,SortedList)


    买家面对面 

    瑞雅商城

    瑞雅淘宝 

    1、string.Split

    string str = "abc$$123$4$5";
    string[] strs = str.Split(new string[] { "$$" }, StringSplitOptions.RemoveEmptyEntries);
    foreach (string s in strs)
    {
      Response.Write(s + "<hr />");
    }

     2、查看指定端口号连接情况

    netstat -abn | find "8800" 

    3、SortedList

    代码
            SortedList<intint> list = new SortedList<intint>(100);
            
    for (int i = 0; i < 100; i++)
            {
                list.Add(i, i 
    + 1000);
            }
            list.TrimExcess();

            
    for (int i = 80; i < 120; i++)
            {
                Response.Write(
    string.Format("InternalID={0}, IndexOfKey={1} <br/>", i, list.IndexOfKey(i)));
                
    int userid = 0;
                list.TryGetValue(i, 
    out userid);//userid不存在会返回0
                Response.Write(string.Format("InternalID={0}, UserId={1} <br/>", i, userid));
                Response.Write(
    "<hr />");
            }

     代码

            SortedList<intint> list = new SortedList<intint>(100);
            
    for (int i = 0; i < 100; i++)
            {
                
    //由小到大排序
                list.Add(Guid.NewGuid().ToString().GetHashCode(), i);
            }
            list.TrimExcess();

            
    foreach (KeyValuePair<intint> kv in list)
            {
                Response.Write(
    string.Format("{0}, {1}", kv.Key, kv .Value));
                Response.Write(
    "<hr />");
            }
  • 相关阅读:
    STL整理之map
    链表及数组模拟链表
    树链剖分详解
    Luogu P3879 【[TJOI2010]阅读理解】
    Luogu P2727 【01串 Stringsobits】
    CF1200D 【White Lines】
    Luogu P4945 【最后的战役】
    Luogu P4944 【PION贪吃蛇】
    Luogu P2426 【删数】
    P2163 【[SHOI2007]园丁的烦恼】
  • 原文地址:https://www.cnblogs.com/chenjunbiao/p/1760301.html
Copyright © 2020-2023  润新知