public class loginbal
{
public static bool match = false ;
public bool check(string username, string password)
{
logindal LGD = new logindal();
DataSet ds1= LGD.logincheck(username, password);
int noofrows = ds1.Tables["login"].Rows.Count;
for (int i = 0; i < noofrows; i++)
{
if ((ds1.Tables["login"].Rows[i]["username_l"].ToString() == username) && (ds1.Tables["login"].Rows[i]["password_l"].ToString() == password))
{
match = true;
}
}
return match;
}
我想回到match
,但它不是与受影响的循环SET语句我可以做什么根据的循环值来改变比赛,回到方法来设置?返回全局变量值内循环
为什么'匹配'是静态的? – Oded
以及为什么你首先需要一个变量?只是当你找到一个匹配时返回true。你也永远不会把'match'重置为'false',所以在你找到一次匹配之后,方法总是返回true。 – BrokenGlass
摆脱你的'match'变量。用'return true'替换'match = true',用'return false'替换'return match'。普雷斯托。 – NullUserException