c# - How to compare a value from a Dictionary<string, string> in a if statement -


using following code, i'm trying compare 1 of parameters of dictionary in if statement i'm getting syntax errors "cannot implicitly convert type string bool"

what way proceed ? thank !

dictionary<string, string>[] responses = service.send(request); foreach (dictionary<string, string> response in responses)             { if (response["result"] = "0")                 {                     messagebox.show("succes !");                 }                 else                 {                     messagebox.show("error !");                 }             } 

result expected return 0 if success or 1 if failed

i've tried following syntax in if give me syntax errors:

if (convert.toboolean(response["result"] = "0"))  if (!string.isnullorempty(response["result"] = "0")) 

thank help, i'm not familiar dictionaries.

= assignment operator while equality operator ==.

the line

response["result"] = "0" 

puts "0" dictionary , returns assigned value, string "0". in c# if expects bool. compile-time error says truth.

you meant

if (response["result"] == "0") 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -