Quote: error CS0019: Operator '>=' cannot be applied to operands of type 'double' and object'maybe i am not using the right 'container' where i need to make sure the object has elements of type double or how would i go about this? thanks!
[.net] C# Array List
hi all i have a C# Array List with some elements that i have added to it. what i am trying to do is use the C++ version of a vector. i think this is the right tool to use. however when i compare a double to an element of the List it complains:
Either define your list like so:
Or during your >= comparison convert the list operand to double using Convert.ToDouble().
using System.Collections.Generic;...List<double> doubleList = new List<double>();
Or during your >= comparison convert the list operand to double using Convert.ToDouble().
Use the generic list, as above.
Your error was likely due to the fact that the compile sees the contents of ArrayList as objects, not doubles (when you put doubles in the list, they are boxed to objects). You'd have to cast the object back to a double for the compiler to allow the comparison.
List<T> is better anyways.
Your error was likely due to the fact that the compile sees the contents of ArrayList as objects, not doubles (when you put doubles in the list, they are boxed to objects). You'd have to cast the object back to a double for the compiler to allow the comparison.
List<T> is better anyways.
thanks all i went ahead and casted them as doubles as i was comparing them. out of curiousity i added the Generic namespace but i got the following error:
Quote:
error CS0234: The type or namespace name 'Generic' does not exist in the class or namespace 'System.Collections' (are you missing an assembly reference?)
Quote:Original post by OpenGL_Guru
thanks all i went ahead and casted them as doubles as i was comparing them. out of curiousity i added the Generic namespace but i got the following error:Quote:
error CS0234: The type or namespace name 'Generic' does not exist in the class or namespace 'System.Collections' (are you missing an assembly reference?)
Sounds like you're using .Net 1.1. So, you'll have to do the casting method to unbox the double.
Quote:Original post by WashuQuote:Original post by OpenGL_Guru
thanks all i went ahead and casted them as doubles as i was comparing them. out of curiousity i added the Generic namespace but i got the following error:Quote:
error CS0234: The type or namespace name 'Generic' does not exist in the class or namespace 'System.Collections' (are you missing an assembly reference?)
Sounds like you're using .Net 1.1. So, you'll have to do the casting method to unbox the double.
i have the .NET Framework 2.0, at least its listed in my add/remove programs..
Visual studio 2005 uses .net 2.0
Visual studio 2003 uses .net 1.1
If you're not using 2005, upgrade asap.
Visual studio 2003 uses .net 1.1
If you're not using 2005, upgrade asap.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement