我试图测试一下工作人员的月份是否等于从他们开始工作到现在的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