Search code examples
c#iosxamarinf#cgrect

CGRect in F# - Undefined


What is the equivalent of CGRect in F#: https://developer.xamarin.com/api/type/CoreGraphics.CGRect/

In C# we do:

new CGRect(50, 0, 200, 100)

but this is undefined in F#...I also tried CGRectMake which was the old syntax, but that doesn't work either. I made sure that I imported CoreGraphics, and also tried CoreGraphics.CGRect.


Solution

  • Your documentation says CGRect constructors take floating point numbers, so try this - assuming you indeed have all the open statements in place:

    CGRect(50.0, 0.0, 200.0, 100.0)

    F# doesn't do implicit conversions of numeric types, you need to use the correct literal for the numeric type you want to use.