I have populated a sorted list of dates(stored as strings in the format dd/mm/yyyy) from an xml file using xpath.
However when querying the list to see if a date exists within the list I always get negative result(i.e. doesnt exist) even though i have hardcode the query string to match a date within the list.
However, when doing a string compare on the index which contains the queried string I get 0 indicating the strings are identical.
What can cause this odd behaviour?
As requested here is the code
Holidays is populated by:
while (iter.MoveNext())
{
XPathNavigator nav2 = iter.Current;
XPathNodeIterator iter2 = nav2.SelectDescendants("date", "", false);
while (iter2.MoveNext())
{
date = iter2.Current.ToString();
holidays.Add(date);
}
}
return holidays;
And the search is:
holidays = list.getHolidays();
if(holidays.BinarySearch(DateTime.Now.ToShortDateString()) > 0)
...
01/01/2009 25/02/2009 10/04/2009 13/04/2009 04/05/2009 25/05/2009 31/08/2009 25/12/2009 28/12/2009
above shows the xml data being used