0

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);
Pål Brattberg
  • 4,568
  • 29
  • 40
user936405
  • 59
  • 1
  • 1
  • 5

1 Answers1

1

If it's boolean, you are over thinking the problem.

SortOrder order = (value) ? SortOrder.Ascending : SortOrder.None;

... or whatever your condition needs to be.

Paul Walls
  • 5,884
  • 2
  • 22
  • 23