枚举怎么和数据挂勾呀?
偶还不会用枚举呢,
大家能不能给说说哈
比如,有一个
public enum RoleEnum:int
{
DevelopGroupLeader,
DevelopGroupMember,
TestGroupLeader,
TestGroupMember,
DeployGroupLeader,
DeployGroupMember,
Branch,
ThirdParty
}
user类里的权限判断
public bool IsInRole(RoleEnum role)
{
return ((role & _re)== role);
}
可
private RoleEnum _re;
private User(DataRow dRows)
{
_AccountName = (string)dRows[ "sAMAccountName "];
_Name = (string)dRows[ "displayName "];
}
怎么实现呀?
------解决方案--------------------_re = (RoleEnum)dRows[Role字段名];
另:
return ((role & _re)== role);
=>
return _re == role;
------解决方案--------------------就是整型的,可以用强制类型转换