What's wrong with this?
if (bool)(UserIDs[i] == ThisUserId)
{
return true;
}
eric.goforth@gmail.com - 17 Mar 2006 21:44 GMT
There's a closing "}", it's inside a function.
if (bool)(UserIDs[i] == ThisUserId)
{
return true;
}
eric.goforth@gmail.com - 17 Mar 2006 21:45 GMT
private bool validateUserId(string ThisUserId, string[] UserIDs)
if (bool)(UserIDs[i] == ThisUserId)
{
return true;
}
AlanT - 17 Mar 2006 21:49 GMT
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[i] == ThisUserID) ) {
return true;
....
Although there should be no need for the (bool)
if ( UserIDs[i] == ThisUserID) {
return true;
...
hth,
Alan.
wfairl@gmail.com - 17 Mar 2006 21:51 GMT
there's no need for anything except return (UserIDs[i] == ThisUserID);
AlanT - 18 Mar 2006 17:56 GMT
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[i] == 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[i] == ThisUserID);
does suffice.
Alan.
wfairl@gmail.com - 17 Mar 2006 21:49 GMT
I'm guessing you mean if((bool) (UserIDs[i] == ThisUserId)) but the
explicit cast is redundant. What are the types of the variables listed?