That's probably because IsInt()
is an extension method that's in System.Web.WebPages.dll
, and you don't have a reference to it.
See MSDN
Question
The isInt doesn't seem to work when put into a class file and i don't understand why. When used within my code it works fine it's just it doesn't like x.IsInt when i moved it into a class file?
public static Boolean Integervalid(string x)
{
bool i = false;
if (x.IsInt())
{
i = true;
}
return i;
}
Solution
That's probably because IsInt()
is an extension method that's in System.Web.WebPages.dll
, and you don't have a reference to it.
See MSDN
OTHER TIPS
You need add the following assembly: System.Web.WebPages (in System.Web.WebPages.dll)
see: http://msdn.microsoft.com/de-de/library/system.web.webpages.stringextensions.isint(v=vs.111).aspx
I suggest to use TryParse to be more independent from the WebPages.dll. TryParse is included in mscorlib
int number;
bool result = Int32.TryParse(value, out number);