错误 1 运算符“>=”不能应用于类型为“方法组”和“方法组”的操作数

本文关键字:方法 方法组 操作数 应用于 运算符 错误 不能 类型 | 更新日期: 2023-09-27 18:33:31

我需要错误帮助(见标题),非常感谢所有帮助。我已经浏览了许多其他人错误的页面,但似乎都没有解决它,如果代码格式不正确,我也很抱歉

public void button11_Click(object sender, EventArgs e)
{
    string weight = (ExtractNumbers(webBrowser1.Document.GetElementsByTagName("table")[2].GetElementsByTagName("td")[11].InnerText));
}
public void webBrowser3_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    string salesrate = (ExtractNumbers(this.webBrowser3.Document.GetElementsByTagName("table")[2].GetElementsByTagName("td")[17].InnerText)); 
}
public void timer9_Tick(object sender, EventArgs e)
{
    *if (weight >= salesrate)
    {
        i am getting this error with this IF statement
    }*
}
public static string salesrate(string expr)
{
    return string.Join(null, Regex.Split(expr, ""));
}
public static string weight(string expr)
{
    return string.Join(null, Regex.Split(expr, ""));
}

错误 1 运算符“>=”不能应用于类型为“方法组”和“方法组”的操作数

根据您发布的代码,以下是更改

string weight= "";
string salesrate = "";

public void button11_Click(object sender, EventArgs e)
{
    weight = (ExtractNumbers(webBrowser1.Document.GetElementsByTagName("table")[2].GetElementsByTagName("td")[11].InnerText));
}
public void webBrowser3_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    salesrate = (ExtractNumbers(this.webBrowser3.Document.GetElementsByTagName("table")[2].GetElementsByTagName("td")[17].InnerText)); 
}
public void timer9_Tick(object sender, EventArgs e)
{
    try {
      var parsedSalesRate = Double.parse(salesrate);
      var parsedWeight = Double.parse(weight);
      if(parsedWeight >= parsedSalesRate) {
          // ...
      }
    } catch(Exception ex) {
           throw;
    }
}

        public static string GetSalesrate(string expr)
        {
            return string.Join(null, Regex.Split(expr, ""));
        }
        public static string GetWeight(string expr)
        {
            return string.Join(null, Regex.Split(expr, ""));
        }