倒序排列:
private static void TestRegex15() { string a = "289506152200"; StringBuilder b = new StringBuilder(); for (int i = a.Length - 2; i >= 0; i = i - 2) { b.Append(a.Substring(i, 2)); b.Append(":"); } if (b.Length > 1) { b.Remove(b.Length - 1, 1); } Console.Write(b); }
两个时间的间隔:
DateTime dtNightEnd = Convert.ToDateTime("2010-6-17 12:00:02"); System.TimeSpan ts = DateTime.Now.Subtract(dtNightEnd); MessageBox.Show(ts.Hours.ToString()); MessageBox.Show(ts.Minutes.ToString()); MessageBox.Show(ts.Seconds.ToString());