错误CS0019运算符'=='不能应用于类型'HttpStatusCode'和'int'的操作数

时间:2018-07-16 02:17:44

标签: c# compilation

您好,我正在尝试编译自己制作的程序,但遇到了一个我不知道如何解决的错误。我已经尝试了所有我能想到的解决方案,并想看看是否有人可以帮助我修复它 这是发生错误的代码。

string text4 = string.Format("X-XSRF-TOKEN={0}&X-XSRF-URI=%2Flogin%2FdoLauncherLogin&fromForm=yes&authType=&linkExtAuth=&epic_username={1}&password={2}&rememberMe=YES", attributeValue, arg, arg2);
httpRequest.Cookies = httpResponse.Cookies;
xNet.HttpResponse httpResponse2 = httpRequest.Post("", text4, "application/x-www-form-urlencoded; charset=UTF-8");
if (httpResponse2.StatusCode == 200)
{
    ref int ptr = ref this.int_0;
    this.int_0 = ptr + 1;
    ptr = ref this.int_2;
    this.int_2 = ptr + 1;
    backgroundWorker.ReportProgress(0, text);
    if (this.bool_0)
    {
          this.queue_1.Enqueue(text2);
    }
}

3 个答案:

答案 0 :(得分:0)

使用枚举HttpStatusCode

if (httpResponse2.StatusCode == HttpStatusCode.OK)

答案 1 :(得分:0)

您应该使用相应的 Enum

if (httpResponse2.StatusCode == HttpStatusCode.OK)

答案 2 :(得分:0)

我相信您需要使用HttpStatusCode枚举,而不仅仅是状态码作为整数。所以

httpResponse2.StatusCode == 200

应该成为

httpResponse2.StatusCode == HttpStatusCode.OK