Cannot convert from int? to int error when applying lookup table(Regional Bound)

when trying the lookup table to validate the GPS taken by interviewer is within the given area, there shows a validation error “Argument 1: cannot convert from int? to int”.

refrence: (Regional Bound)

try island.Value instead of island.

It did not work, now is shows “cannot convert from ‘double?’ to ‘double’.”

Try to recast all values within location:

location[(double)island.Value]

if you are implying that I should try this:
GPS.InRectangle(location[(double)island.Value].N,location[(double)island.Value].E,location[(double)island.Value].S,location[(double)island.Value].W)

it did not work

assuming question island is a single-select then try:

GPS.InRectangle(location[(int)island].N,location[(int)island].E,location[(int)island].S,location[(int)island].W)

GPS.InRectangle(
    location[island.Value].N.Value,
    location[island.Value].E.Value,
    location[island.Value].S.Value,
    location[island.Value].W.Value)
1 Like

If that matters, the InRectangle() function expects its arguments in the following order:

  • North,
  • West,
  • South,
  • East.

The code above will compile, but will give unexpected result unless your question variable names are similarly swapped.

thank you sergiy, it worked