retrieving dictionary value
I've got a dictionary that stores a string key and a bool as it's value. How do I retrieve the bool value for use in an if-statement? Currently I'm doing this:
11 Replies
I think if I remove the
tempLurkStatus == true
and just put the TryGetValue
alone, it'll return true if the value exists, but not if the bool is true, right?yup
so how would I check if the bool is true?
do I have to retrieve the bool and store it in a temporary var outside the if statement?
or can I do it inside somehow?
you can inline it
your ide should suggest that
stored bool is true -> pass
stored bool is false -> fail
key doesn't exist -> fail
this is what I want the if statement to check
that's what you're doing, yup
doesn't seem to work though
if the code is correct, then I guess I'll have to check why it's not working...
alright just to confirm - the code I put up there is correct right?
yes
== true
is redundant but yeswait it is?
I thought if I didn't add that, it'd just check if the key exists
myBool == true
is the same as myBool
oh yeah. true.