从函数返回值时出错

从函数返回值时出错

本文介绍了从函数返回值时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,
查看我的代码,

Hello Friends,
Go through my code,

protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        clsUser objUser = new clsUser();
        Hashtable hstUser = new Hashtable();
        hstUser.Add("username", Login1.UserName);
        hstUser.Add("pwd", Login1.Password);
        objUser.setDetails(hstUser);

        if (Validate(objUser) == true)
        {
            Response.Redirect("..\\Pages\\frmRegistration.aspx");
        }
        else
            e.Authenticated = false;
    }
    private bool Validate(clsUser objUser) //Line1
    {
        UserBLL objUserBLL = new UserBLL();
        int intResult = objUserBLL.ValidateLogin(objUser);
        if(intResult > 0)
            return true;
        else if(intResult < 0)
            return false;
    }



我在Line1遇到错误,说:



I''m getting error at Line1 saying:

''_Default.Validate(clsUser)'': not all code paths return a value	<br />



谁能帮我解决问题?

在此先感谢.



Can anyone help where I''m going wrong?

Thanks in advance.

推荐答案

private bool Validate(clsUser objUser) //Line1
        {
            bool flag = false;

            UserBLL objUserBLL = new UserBLL();
            int intResult = objUserBLL.ValidateLogin(objUser);
            if (intResult > 0)
                flag = true;
            else if (intResult < 0)
                flag = false;

            return flag;
        }


return true


private bool Validate(clsUser objUser) //Line1
    {
        UserBLL objUserBLL = new UserBLL();
        int intResult = objUserBLL.ValidateLogin(objUser);
        if(intResult > 0)
            return true;
        else if(intResult < 0)
            return false;
       return true;
    }


这篇关于从函数返回值时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-15 06:21