我試圖測試一下工作人員的月份是否等於從他們開始工作到現在的3個月。而這正是我試圖使用方法:startIndex不能大於c中字符串的長度#
int totalMonth = 3;
int totalYear = 0;
int mon = DateTime.Now.Month;
int yr = DateTime.Now.Year;
//block of code that I used LinQ to Entity to get staff start work date
result = result.Where(((s => mon - int.Parse(s.StartDate.Substring(3, 2).ToString()) == totalMonth && yr -int.Parse(s.StartDate.Substring(6, 4).ToString()) == totalYear))).ToList();
日起在我的數據庫格式07/05/2012
但我得到的錯誤:
startIndex cannot be larger than length of string. Parameter name: startIndex
可以在任何一個可以告訴我,我怎麼錯在這裏?先謝謝了。
您的代碼適用於名爲result的變量。但我們無法看到這種類型或其當前價值。你能詳細解釋一下嗎? – Steve 2012-08-12 12:35:30