将布尔值转换为 SortOrder 枚举值
我正在使用 ADO.NET
中的数据读取器从表中读取布尔值(值将为 1
或 0
),并希望输入强制转换值到 SortOrder
(http://msdn.microsoft.com/en-us/library/dscy145f.aspx)。
如果我使用 Enum.TryParse
方法来转换值,我会收到错误。任何替代解决方案。
SortOrder order;
Enum.TryParse<SortOrder>(bool value);
i am reading boolean value (value would either 1
or 0
) using data reader in ADO.NET
from a table and want to type cast value to SortOrder
(http://msdn.microsoft.com/en-us/library/dscy145f.aspx).
I am getting error if i use Enum.TryParse
method to convert value. Any alternative solution.
SortOrder order;
Enum.TryParse<SortOrder>(bool value);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果它是布尔值,则说明您对问题的思考过度了。
...或任何您需要的条件。
If it's boolean, you are over thinking the problem.
... or whatever your condition needs to be.