As the error suggests, the AsInt
method is an extension method. Just add some brackets to call the method, also missing an extra =
, as per the comments:
var pageSize = 0;
if (Request.QueryString["pagesize"].AsInt() == 10)
{
pageSize = 10;
}
else
{
pageSize = 6;
}
You can further simplify your code by taking advantage of the conditional operator. The following line achieves the same result:
var pageSize = Request.QueryString["pagesize"].AsInt() == 10 ? 10 : 6;