Suppose I have to call a function with the following signature: DoStuff (Int32?)
I want to convey the doStuffvalue that is read from Request.Form. However, if the passed value is empty, missing or not a number, I want doStuffan empty argument to be passed. This should not lead to an error; this is an operation.
I have to do this with eight such values, so I would like to know what is an elegant way to write in C #
var foo = Request.Form["foo"];
if (foo is a number)
doStuff(foo);
else
doStuff(null);
source
share