How to calculate which zip code is closer to which in USA using C#?

المشرف العام

Administrator
طاقم الإدارة
I'm not living in USA, and I'm doing a small project for a company based in USA. The point is that, there are businesses and each of them have their address and zip code. Then, I have a form where users fill their zip code. Afterwards, I need to take the 5 businesses which are closer to the user by zip code. Any idea how to do the comparison?

I already asked the question in SO, but they directed me to ask here, which also seems to make more sense. As I said I'm not from USA, but the thing that confuses me is that some of the zip code entries in the database have two number separated by dash, and some just one number, for example in Kentucky, I have both of these zip codes: 40507-1532, 40014, where as you can see, one of them is just one number, and the other is two numbers separated by a dash. I don't know whether it is a valid zip code for USA or not.

Anyway, what is the simplest method that I can check the zip codes closest to the given zip code.



أكثر...
 
أعلى