这个片段可以缩短,所以它仍然显示当前时间
像这样:08:24:09?
而不是这样 8:24.9
我目前的代码:
this.lblClock = new System.Windows.Forms.Label();
this.lblClock.Text = "00:00:00";
时钟滴答声:
private void _Clock_Tick(object sender, EventArgs e)
{
DateTime CurrTime = DateTime.Now;
if (CurrTime.Hour > 9 && CurrTime.Minute > 9 && CurrTime.Second > 9)
lblClock.Text = ("" + CurrTime.Hour + ":" + CurrTime.Minute + ":" + CurrTime.Second);
if (CurrTime.Hour < 10 && CurrTime.Minute > 9 && CurrTime.Second > 9)
lblClock.Text = ("0" + CurrTime.Hour + ":" + CurrTime.Minute + ":" + CurrTime.Second);
if (CurrTime.Hour > 9 && CurrTime.Minute > 9 && CurrTime.Second < 10)
lblClock.Text = ("" + CurrTime.Hour + ":" + CurrTime.Minute + ":" + "0" + CurrTime.Second);
if (CurrTime.Hour < 10 && CurrTime.Minute > 9 && CurrTime.Second < 10)
lblClock.Text = ("0" + CurrTime.Hour + ":" + CurrTime.Minute + ":" + "0" + CurrTime.Second);
if (CurrTime.Hour > 9 && CurrTime.Minute < 10 && CurrTime.Second > 9)
lblClock.Text = ("" + CurrTime.Hour + ":" + "0" + CurrTime.Minute + ":" + CurrTime.Second);
if (CurrTime.Hour < 10 && CurrTime.Minute < 10 && CurrTime.Second > 9)
lblClock.Text = ("0" + CurrTime.Hour + ":" + "0" + CurrTime.Minute + ":" + CurrTime.Second);
if (CurrTime.Hour > 9 && CurrTime.Minute < 10 && CurrTime.Second < 10)
lblClock.Text = ("" + CurrTime.Hour + ":" + "0" + CurrTime.Minute + ":" + "0" + CurrTime.Second);
if (CurrTime.Hour < 10 && CurrTime.Minute < 10 && CurrTime.Second < 10)
lblClock.Text = ("0" + CurrTime.Hour + ":" + "0" + CurrTime.Minute + ":" + "0" + CurrTime.Second);
}
你能缩短那个片段吗?