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);
Int is a value type which means there is no such thing as a null int. So no, TryParse will never alter the out parameter so that it is null.
But the problem you're having is you're passing a string to the out parameter of TryParse when its expecting an integer.
You need something like this...
Int categoryID = 0;
string strCategoryID = "somestringmaybeitsaninteger";
int.TryParse(strCategoryID, out categoryID);