1

I found this question: Why "decimal" is not a valid attribute parameter type? when I was searching for a solution to my original problem and understand that it is not an option, however, I am now curious as to how I should handle converting the value.

Would the best option be to just pass in doubles and then convert the attribute values to decimal or convert the property's value to double?

The actual implementation of the business logic is using IComparable so I have to do some sort of conversion. I am just not sure which way is best or if there was a neat workaround for handling the need for decimals in Attribute classes.

Community
  • 1
  • 1
TyCobb
  • 8,909
  • 1
  • 33
  • 53
  • Hard-coded decimal values are ... weird. Might as well use a string. – Hans Passant Dec 13 '13 at 03:02
  • @HansPassant I understand that and I can easily make it convert from a string to decimal if needed since I am in control of the actual business rule this will be applied to. I just want to make sure I go about it the best way so I am not running into a weird rounding error and wasn't sure if there was a legitimate workaround I didn't find. – TyCobb Dec 13 '13 at 03:10
  • Yah, strings don't have rounding errors. – Hans Passant Dec 13 '13 at 03:23
  • @HansPassant Sounds good. If you want to make an answer, I'll mark it. Thanks for your insight. – TyCobb Dec 13 '13 at 03:26

1 Answers1

0

Went with using a string to handle the rounding issues as Hans mentioned.

If anyone has a better idea, please answer this question and I will mark it.

TyCobb
  • 8,909
  • 1
  • 33
  • 53