我有以下方法和枚举:
public int GetRowType(string pk)
{
return Convert.ToInt32(pk.Substring(2, 2));
}
public enum CONTENT {
Menu = 0,
Article = 1,
FavoritesList = 2,
ContentBlock = 3,
Topic = 6,
List = 7
};
Run Code Online (Sandbox Code Playgroud)
在这里,我试图检查我的方法的结果是否等于枚举的值,但我收到一个错误:
GetRowType(content) == CONTENT.Topic
Run Code Online (Sandbox Code Playgroud)
有人能给我一些关于我做错的建议吗?
Gives me an error: Error 2
Operator '==' cannot be applied to operands of type 'int' and 'Storage.Constants.CONTENT'
Run Code Online (Sandbox Code Playgroud)
只需将enum值明确地转换为int
GetRowType(content) == (int)CONTENT.Topic
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
84 次 |
| 最近记录: |