c# - Bing Maps Location object - how is equality determined? -


in code i'm running, have 2 different instances of location object bing maps api:

location l1 = new location(50, 50); location l2 = new location(50, 50); 

however when run console.writeline(l1.equals(l2)) false. why that? , how override equals , gethashcode methods such above evaluates true?

i'd note reason finding documentation location has been impossible me.(nevermind, found it: here it's still not helpful) i've tried looking directly @ definition of location object find equals , gethashcode methods no avail.

thanks!

it's worth pointing out documentation not define equals method. means equals method seeing defined .net , compares object addresses noted graffito.

when comes comparing coordinates should @ first 5 or 6 decimal places. 6 decimal places has accuracy of 10cm in cases close enough same. if direct comparison of decimal places may find coordinates meant same not due floating point error might occur somewhere down line. here way check if 2 location objects same:

public bool areequal(location l1, location l2){     return math.round(l1.latitude, 6) == math.round(l2.latitude, 6) &&         math.round(l1.longitude, 6) == math.round(l2.longitude, 6); } 

Comments