2021年3月10日 星期三

TimePicker System.FormatException: 'Input string was not in a correct format.'

 今天在處理時間格式時遇到一個問題

通常我們要把時間輸出成 小時:分鐘:秒數 會是DateTime.Now.ToString("HH:mm:ss");

然而事情總有意外,在使用TimePicker 時  

xaml的部份:

                   <TimePicker  x:Name="StartTime"

                    Time="08:00:00"

                    Format="HH:mm"/>

程式如下:

string  StartTime=  StartTime.Time.ToString("HH:mm");

乾~~~~一杯咧!

System.FormatException: 'Input string was not in a correct format.'

報錯了!

好唄,只能問大神,改成如下:

string StartTime = StartTime.Time.ToString(@"hh\:mm");

我還不知道為什麼,還在找答案中.........

沒有留言:

張貼留言

簽署時發生錯誤: 無法簽署 bin\Debug\app.publish\XXX.exe。SignTool Error: No certificates were found that met all the given criteria.

 這是一個程式碼簽署憑證的問題。當您的專案設定要進行程式碼簽署,但系統找不到合適的憑證時就會出現這個錯誤。以下是幾種解決方法: 方法 1:移除程式碼簽署設定 如果您不需要程式碼簽署,可以在專案中移除相關設定: 在 Visual Studio 中右鍵點擊專案 → 屬性 點擊「...