c# - Checking value of JSON property fails to compare to string -
i'm building user registration , store user data in json files. reason can't compare value of property string. sample code:
public bool isregistered() { jobject data = jobject.parse("{\"registered\":\"yes\"}"); var registered = data["registered"]; if (registered != "yes") { return true; } return false; }
i error on if (registered != "yes")
operator of type != cannot used in operand of type jtoken , string
because registered
of type jtoken
, can not compare string
. can cast string
this:
var registered = (string)data["registred"]; if (registered != "yes")
Comments
Post a Comment