Conversion from GH_Number to Double

unhandled

#1

Hi,
I am trying to convert/cast Object to Double, and get the following message:

image

How to fix?

Thanks,
Dmitriy


(Nathan 'jesterKing' Letwory) #2

In C# it would be:

GH_Number n = GetTheGHNumberSomehow();
double d = (double)n.Value;

#3

I would have guessed, that if the original type is object, you’ll need to cast to GH_Number first, and that you then should be able to directly access the Value without casting.

object a = new GH_Number(17.0);
GH_Number b = (GH_Number) a;
double c = b.Value;

(Nathan 'jesterKing' Letwory) #4

Right, I fell over the float vs float32 naming in F# - I was looking at GH_Number.Value in some F# code of mine, it said float, completely forgetting it is actually double.


#5

Thanks. It works.


(Nathan 'jesterKing' Letwory) #6

2 posts were split to a new topic: Possible to write F# code for Grasshopper?