If I compare the HistoryScale of two BarsHistory (both Daily) by using Scale1.CompareTo(Scale2) I get -1. Shouldn't it return 0 ? When I use == operater, it returns true, as expected?
Rename
No, if you want to test Equality, use Equals.
CompareTo is used to determine if the scale is greater (higher) than the one "on the right". If it's not greater, then CompareTo returns -1, otherwise 1 if it's greater.
Example:
HistoryScale.Daily.CompareTo(HistoryScale.Minute30) will return 1, because Daily is a higher scale than 30 minute bars.
CompareTo is used to determine if the scale is greater (higher) than the one "on the right". If it's not greater, then CompareTo returns -1, otherwise 1 if it's greater.
Example:
HistoryScale.Daily.CompareTo(HistoryScale.Minute30) will return 1, because Daily is a higher scale than 30 minute bars.
ok, thanks (I assumed IComparable documentation on docs.microsoft.com)!
Hmm, good point. Unless Glitch implemented it that way specifically, we could change it to return 0 for equality. Glitch?
I made it return zero if equal for Build 6.
Your Response
Post
Edit Post
Login is required