I am trying to debug a method in C #, but my basic syntax skills here seem to be missing! The method accepts the list of dates as a text string, separated by commas. This string is converted to a list and then processed. However, it seems that even when an empty string is passed to the method, it still outputs 1 when the list is counted.
The code is as follows:
public static int DaysLeft(DateTime endDate, DateTime startDate, Boolean excludeWeekends, String excludeDates) { int counter = 0; List<string> excludeDatesList = new List<string>(excludeDates.Split(',')); counter = excludeDatesList.Count; return counter; }
If I pass an empty string as an excludeDates parameter, it returns 1. If I pass one date, it returns 1. If I pass two dates, it returns 2, etc. So this is the kind of work, except when nothing went in, when I expect it to return 0, but actually returns 1.
Can someone point me in the right direction?
thanks
source share