开发者

convert boolean value to SortOrder enum value

开发者 https://www.devze.com 2023-04-03 13:37 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消