我有一个这样定义的枚举类型:
public enum Status
{
Active=1,
InActive=0
}
在我的方法中,我可以像这样将参数转换为枚举:
public string doSomething(string param1, int status)
{
//will this work?
Account.Status = (Status) status;
//or do i need to test one by one like this
if(status == 0)
{
Account.Status = Status.Inactive;
//and so on...
} // end if
} // end doSomething