假如字符串
2008-11-1 8:42:00
2008-11-23 16:42:00
怎么才能取空格以后的所有位数呀~所要的结果是
8:42:00
16:42:00

解决方案 »

  1.   

     string str = @"2008-11-1 8:42:00";
            int indexlen = str.IndexOf(" ", 1);
            int leng = str.Length - indexlen;        string newstr = str.Substring(indexlen,leng);
      

  2.   

    string str = @"2008-11-1 8:42:00"; 
            int indexlen = str.IndexOf(" ", 1); 
            int leng = str.Length - indexlen;         string newstr = str.Substring(indexlen,leng);
      

  3.   

    string str = "2008-11-1 8:42:00";
    Console.WriteLine(str.Substring(str.IndexOf(" "),str.Length - str.IndexOf(" ")));
    Console.ReadKey();
      

  4.   

                string s = "2008-11-23 16:42:00";
                string s1 = s.Substring(12, s.Length - 12);
                Console.Write(s1);
      

  5.   

    用string.splite 方法,把字符串按 分隔符生成数组,然后取数组的内容
      

  6.   

     string Temp = "2008-11-1 8:42:00";
                Temp = Temp.Remove(0, Temp.IndexOf(' ')).Trim();
      

  7.   

    string time = @"2008-11-1 8:42:00".Splite(' ')[1]; 
      

  8.   

    正则
    Regex.Match("2008-11-1 8:42:00",@"(?<=\s)\d{1,2}:\d{1,2}:\d{1,2}").Value
      

  9.   

    假如只是要取时间的
    小时:分钟:秒
    的话这里也可以实现        string time = "2008-11-1 8:42:00";
            DateTime dt = Convert.ToDateTime(time);
            time = dt.ToString("hh:mm:ss");如果本来就是DateTime就是不需要转换了