0
我有一個TimeSpan
,其格式爲@"hh\:mm\:ss\.fff"
,並且希望使用xceed(https://wpftoolkit.codeplex.com/wikipage?title=MaskedTextBox&referringTitle=Home)中的MaskedTextBox
來幫助用戶輸入有效的時間範圍。將TimeSpan格式字符串轉換爲InputMask
現在我轉換FormatString
,物業到輸入掩碼像這樣
public string InputMask
{
get
{
string mask = FormatString.Replace('h', '0');
mask = mask.Replace('m', '0');
mask = mask.Replace('s', '0');
mask = mask.Replace('f', '0');
mask = mask.Replace('d', '0');
return mask;
}
}
這個解決方案看起來醜陋,而不是維護,如果formatString的獲得,我還不知道另一種格式。有沒有更優雅的解決方案(例如用正則表達式替換),用0
取代任何字母?
[這](http://stackoverflow.com/questions/9975640/check-if-char-isletter)?但我會用'for(int i = 0; i
Sinatr
這不起作用,因爲'mask [i]'沒有setter,而字符串是不可變的。 – Herm
然後我會來stackoverflow和張貼在這裏我的問題= D – Sinatr