Why can't I do this?
if ((bool)Request["genericError"] != true)
{
return;
}
Compiler gives me:
Cannot convert type 'string' to 'bool'
Request["genericError"]
should be an object, so why does the compiler think its a string?
I'm looking for the reason for this, not how to sidestep it (using Convert
)
What makes you think that Request["genericError"]
should be an object?
Assuming Request
is an HttpRequest
(as I suspect), the indexer is of type string.
Because it is a string. Try:
if ( bool.parse (Request["genericError"] ) != true) return;
Better yet,
use `bool.TryParse' etc ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With