سؤال

I would like to check if my variable is an integer in controller. In view I can easily use isInt() but not in the controller. Do I need to have a special reference to use that method?

Thank you.

هل كانت مفيدة؟

المحلول

If you add the following namespace you can use it in your controller.

using System.Web.Webpages;

Depending on your usage you might want to use Int32.TryParse() instead.

نصائح أخرى

int result;
if (int.TryParse(x, out result))
{
    // do something with result, which is a "strong" int
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top