cannot implicitly convert type string to bool

  • Thread starter Thread starter eric.goforth
  • Start date Start date
There's a closing "}", it's inside a function.

if (bool)(UserIDs == ThisUserId)
{
return true;
}
 
private bool validateUserId(string ThisUserId, string[] UserIDs)


if (bool)(UserIDs == ThisUserId)
{
return true;
}
 
You are not converting types here. the result of the == is a bool not
a string. It looks like missing parentheses

The statement should be something along the lines of

if ( (bool)(UserIDs == ThisUserID) ) {
return true;
....

Although there should be no need for the (bool)

if ( UserIDs == ThisUserID) {
return true;
...


hth,
Alan.
 
I'm guessing you mean if((bool) (UserIDs == ThisUserId)) but the
explicit cast is redundant. What are the types of the variables listed?
 
Sort of.

It's not clear from the original posting whether there was an altermate
action on if they didn't match ( there is no closing brace, so it
looks like a snippet rather than the whole routine.)

e.g

if ( UserIDs == ThisUserID) {
return true;
}
else {
LogErrorMessage();
DoInterestingThings();
}


If the only thing that the routine does is check the validity of the
user ID and return true/false, then

return (UserIDs == ThisUserID);

does suffice.


Alan.
 
Back
Top