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.
変数がコントローラーの整数かどうかを確認したいと思います。ビューでは、isInt()を簡単に使用できますが、コントローラーでは使用できません。そのメソッドを使用するには、特別な参照が必要ですか?
ありがとうございました。
次の名前空間を追加すると、コントローラーで使用できます。
using System.Web.Webpages;
使用法によっては、代わりにInt32.TryParse()を使用することをお勧めします。
int result; if (int.TryParse(x, out result)) { // do something with result, which is a "strong" int }