I have a problem where I need to compare two objects but of course you can't do this with ordinary objects. I figure I need to cast the objects to their respective types first and then compare them. I don't really know what the object types will be so I can't just tell myself in code. Really, it seems like I need a cast function that I can pass the object type into and have it cast the object. Here is a code-snipit:

Code:
        public string FnLessThan(FSFunction fn)
        {
            // LessThan( val1, val2 )
            object v1, v2;
            Object val1 = parser.FindObject(fn.GetParm(0));
            if (val1 != null)
                v1 = val1.Obj;
            else
            {
                v1 = new Double();
                v1 = Convert.ToDouble(fn.GetParm(0));
            }
            Object val2 = parser.FindObject(fn.GetParm(1));
            if (val2 != null)
                v2 = val2.Obj;
            else
            {
                v2 = new Double();
                v2 = Convert.ToDouble(fn.GetParm(1));
            }
            if (v1 < v2)
                return "True";
            return "False";
        }
The error is at the 'if(v1<v2)'. It says something like you can't do this with objects.

Thanks,
I'm using .NET 4.0