Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
小数点やパーセント記号のない数値でテキストボックスを検証する必要があります。例:
1%、15%、78%、100%。
どうすればこれを達成できますか?
それを試してみてください。
var value = "10%".Trim('%'); int no; if(tryParse(value, out no)) { // Your code here }
文字列置換関数を使用してパーセント記号を削除してから、TryParse to integer を使用して、有効な数値があるかどうかを確認します。