gpt4 book ai didi

c# - 类、结构或接口(interface)成员声明中的无效标记 'return'

转载 作者:行者123 更新时间:2023-11-30 19:12:35 25 4
gpt4 key购买 nike

return found;

正在给予:

Invalid token 'return' in class, struct, or interface member declaration

代码:

public bool IsTextPresent(ISelenium Selenium, string searchText)
{

int count = (int)Selenium.GetXpathCount("//*[@id='resultTable']/table");
string text;

bool found;

for (int i = 1; i <= count; i++)
{
StringBuilder container = new StringBuilder();

for (int j = 4; j <= 8; j += 2)
{

if (Selenium.IsElementPresent("xpath=/html/body/form/div[2]/table[" + (i) + "]/tr[" + (j) + "]/td[4]"))
{
text = Selenium.GetText("xpath=/html/body/form/div[2]/table[" + (i) + "]/tr[" + (j) + "]/td[4]");


container.Append(text + Environment.NewLine);
}

string fullText = container.ToString();
if (!fullText.Contains(searchText))
{
found = false;
}
else
{
found = true;
}
}
}
}
return found;
}

最佳答案

你有太多的右大括号......你的缩进 if 在结束时混淆了你的结束 }s 的数量:

        string fullText = container.ToString();
if (!fullText.Contains(searchText))
{
found = false;
}
else
{
found = true;
}
} // <<<< The indention of the if probably threw you off here...

关于c# - 类、结构或接口(interface)成员声明中的无效标记 'return',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6683484/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com