一串特殊的字符
如: {FileTransmission.exe|2009/12/23 15:02:05}{FileTransmission.vshost.exe|2009/12/23 15:02:00}{SQLbackup.exe|2009/12/25 16:13:48}{SQLbackup.vshost.exe|2009/12/25 16:30:12}{7z.dll|2009/12/24 23:02:00}{SevenZipSharp.dll|2009/12/24 23:02:00}
转换为Hashtable。
Hashtable 主键为 | 前面的 值为 | 后面的时间本人很鹾,不会写,会的帮个忙。谢谢

解决方案 »

  1.   

    这是很简单的分解字符串嘛...另外Hashtable过时了,能不用就别用...
    string s = "{FileTransmission.exe|2009/12/23 15:02:05}{FileTransmission.vshost.exe|2009/12/23 15:02:00}{SQLbackup.exe|2009/12/25 16:13:48}{SQLbackup.vshost.exe|2009/12/25 16:30:12}{7z.dll|2009/12/24 23:02:00}{SevenZipSharp.dll|2009/12/24 23:02:00}";
    var r = s.Split(new char[] { '}', '{' }, StringSplitOptions.RemoveEmptyEntries);
    Dictionary<string, string> d = new Dictionary<string, string>();
    foreach (var item in r)
    {
        var i = item.Split(new char[] { '|' });
        d.Add(i[0], i[1]);
    }
      

  2.   


        Hashtable tab = new Hashtable();
    string Text = "{FileTransmission.exe|2009/12/23 15:02:05}{FileTransmission.vshost.exe|2009/12/23 15:02:00}{SQLbackup.exe|2009/12/25 16:13:48}{SQLbackup.vshost.exe|2009/12/25 16:30:12}{7z.dll|2009/12/24 23:02:00}{SevenZipSharp.dll|2009/12/24 23:02:00}";
    MatchCollection M = Regex.Matches( Text , @"\{(.*?)\}" );
    string[] Temp;
    foreach(Match N in M)
    {
    Temp = N.Groups[1].Value.Split('|');
            tab[Temp[0]] = Temp[1];
    }
      

  3.   

    string s = ";
    string[] arr = s.Split(new char[] { '}', '{' }, StringSplitOptions.RemoveEmptyEntries);
    Hashtable ht= new Hashtable();
    foreach (string s in arr)
    {
        strin[] arr2= s.Split(new char[] { '|' },StringSplitOptions.RemoveEmptyEntries);
        ht.Add(arr2[0],arr2[1]);
    }