错误 1 由于“BLL.UserManager.Adduser(Models.User)”返回 void,返回关键字后面不得有对象表达式 C:\Users\Admin\Desktop\Blog\Blog\BLL\UserManager.cs 33 13 BLLusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using Models;namespace BLL
{
    public static  class UserManager
    {
        public static bool UserLogin(string loginname, string loginpwd, out User validUser)
        {
            User user = Userservice.GetUserByLonginName(loginname);
            if (user == null)
            {
                validUser = null;
                return false;
            }
            else if (user.Loginpwd != loginpwd)
            {
                validUser = null;
                return false;
            }
            else
            {
                validUser = user;
                return true;
            }
        }
        public static void Adduser(User user)
        {
            return Userservice.Adduser(user);   
            // 返回关键字后面不得有对象表达式的问题   
        }
        public static bool UserReister(User user)
        {
            if (Userservice.GetUserByLonginName(user.Loginname) != null)
            {
                return false;
            }
            else
            {
                Adduser(user);
                return true;
            }
        }
    }
}这个是什么问题呢 。求解释啊 。。

解决方案 »

  1.   

    void的return不能带表达式,这样就可以了
    public static void Adduser(User user)
      {
          Userservice.Adduser(user);   
      // 返回关键字后面不得有对象表达式的问题   
      }
      

  2.   

    public static boolAdduser(User user)
      {
      return Userservice.Adduser(user);   
      // 返回关键字后面不得有对象表达式的问题   
      }
      public static bool UserReister(User user)
      {
      if (Userservice.GetUserByLonginName(user.Loginname) != null)
      {
      return false;
      }
      else
      {
      Adduser(user);
      return true;
      }
      }
      }
    要么这样,要不就在return后面不加任何东西