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
m开发者_如何学JAVAethod to convert value. Any alternative solution.
SortOrder order;
Enum.TryParse<SortOrder>(bool value);
If it's boolean, you are over thinking the problem.
SortOrder order = (value) ? SortOrder.Ascending : SortOrder.None;
... or whatever your condition needs to be.
精彩评论