Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
> operator vs. datarow column of System.Decimal type?
Message
 
To
02/12/2003 15:35:28
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00855035
Message ID:
00855188
Views:
19
Well I'll be darned. I would have sworn that was _exactly_ what I originally tried and it gave me a compile error about not being able to use the > operator with an object. Obviously, I must have had a slightly different, non-working hunk of code at the time. Maybe I was going to (int) vs. (decimal) and the cast wasn't valid. I only went the CompareTo() route after it appeared to me that > was not allowed for whatever reason.

Now casting to decimal and using the > operator _does_ work in one line, as I had suspected it should. Thanks!

>Kelly,
>
>I just wonder why you bothered with the CompareTo method? Couldn't you just have used this:
>
>if ((decimal)drQuery["SalesMin"] > 0)
>
>
>~~Bonnie
>
>>Good thought, thanks. I actually had tried that earlier with similar failure as trying to cast to int. However, based on your suggestion, I did find something that works. The reason that it didn't work for me before (the commented line below) was that "inline" casting apparently doesn't allow access to the methods of the casted type (I'm just guessing here, but Intellisense wouldn't pop up the list of Decimal members and at runtime I was told that CompareTo was not a member of the object).
>>
>>
>>//if ((decimal)drQuery["SalesMin"].CompareTo( (decimal)0 ) > 0)
>>decimal SalesMin = (decimal)drQuery["SalesMin"];
>>if (SalesMin.CompareTo( (decimal)0 ) > 0)
>>
>>
>>Thanks to everyone for the suggestions.
>>Kelly
>>
>>>From your original post, you said the data column was decimal, so I assume you want to cast it to decimal, not int. I bet that will work just fine.
>>>
>>>~~Bonnie
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform