C#中关于struct的问题,百思不得其解?????
namespace CRM_LANDSERVER.classPackage
{
public struct UserDataRight
{
public bool UserDelRight; //删除权限
public bool UserSelRight ; //查询权限
public bool UserAddRight; //新增权限
public bool UserEditRight; //编辑权限
public bool UserSaveRight; //保存权限
}
public class UserCharacter
{
protected string strUserID;
public UserCharacter()
{
}
public UserCharacter(string UserID)
{
this.strUserID=UserID;
}
public void UserValRight(out UserDataRight userDataRight){
try
{
//此处连接数据库部分省略 SqlDataReader userGroupRecord=cmdUserRight.ExecuteReader();
//初始化权限
userDataRight.UserAddRight=false;
userDataRight.UserDelRight=false;
userDataRight.UserEditRight=false;
userDataRight.UserSaveRight=false;
userDataRight.UserSelRight=false;
while(userGroupRecord.Read()){
//判断是否有查询权限
if(userGroupRecord.GetValue(3).ToString()=="1"){
userDataRight.UserSelRight=true;
}
}
userGroupRecord.Close();
}
catch(SqlException sqlE){
MessageBox.Show("数据库连接错误!"+sqlE.ToString(),"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
}catch(Exception e){MessageBox.Show("异常错误!"+e.ToString(),"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
}
}
////////////////////调用部分的代码是
UserCharacter userRightCharacter=new UserCharacter("001");
UserDataRight userDataRights;
userDataRights=new UserDataRight();
userRightCharacter.UserValRight(out userDataRights);
if(userDataRights.UserSelRight==true)
{
MessageBox.Show("有新增权限");
}else{
MessageBox.Show("sdddd");
}
////////////////////
错误是E:\CRM\CRM_LANDSERVER\classPackage\UserCharacter.cs(50): The out parameter 'userDataRight' must be assigned to before control leaves the current method