I have the following code which fetches a country ID based on the IP address:
countryID = GetAllCountryIPRanges().Single(c => c.BeginIPNum <= intIp && intIp <= c.EndIPNum).CountryID;
It's unfortunately quite slow as there's ~200,000 records. The ranges do not overlap, and GetAllCountryIPRanges()
is in ascending order by BeginIPNum
.
How do I implement .BinarySearch()
on this list to find the correct record?