is there some way of return null if it can\'t parse a string to int?
with:
public .... , string? categoryID)
{
int.TryParse(categoryID, out categoryID);
** this answer was down-voted a lot ** Although it is a possible solution - it is a bad one performance wise, and probably not a good programming choice.
I will not delete it, as I guess many programmers might not be aware of this, so here is an example how not to do things:
use try and catch
try
{
res = Int32.Parse(strVAR)
}
catch(exception ex)
{
return null;
}