我正在使用GET JSON请求来了解事务的状态(每5秒检查一次):
string webAddr = "https://shapeshift.io/txStat/" + textBox1.Text;
var httpWebRequest = (HttpWebRequest)WebRequest.Create(webAddr);
httpWebRequest.ContentType = "application/json; charset=utf-8";
httpWebRequest.Method = "GET";
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var responseText = streamReader.ReadToEnd();
var apiResponse = JsonConvert.DeserializeObject<TransactionStatus>(responseText);
}
if (TransactionStatus.status = "no_deposits")
{
label7.Text = "Pending..";
}
else if (TransactionStatus.status = "received")
{
label7.Text = "Received..";
}
else if (TransactionStatus.status = "complete")
{
label7.Text = "Completed !";
}
else
{
label7.Text = "...";
}
我的问题是我无法检查此字符串值,因为它需要是“bool”。如何将其更改为bool?或者还有其他方法可以做我正在尝试做的检查吗?谢谢!
答案 0 :(得分:2)
== not =。
TransactionStatus.status = "no_deposits"
应该是
TransactionStatus.status == "no_deposits"
否则它认为您为状态分配值,而不是比较它。