I am trying to use TryParse to find if the string value is an integer. If the value is an integer then skip foreach loop. Here is my code.
string strValue = "42 "
if (int.TryParse(trim(strValue) , intVal)) == false
{
break;
}
intVal is a variable of type int?(nullable INT). How can I use Tryparse with nullable int?
You can’t do this without using another variable, unfortunately – because the type of
outarguments has to match the parameter exactly.Like Daniel’s code, but fixed in terms of the second argument, trimming, and avoiding comparisons with Boolean constants: