在以下方法中,参数fromDate和toDate的值从未被使用,因为它们在被读取之前在函数体内被覆盖了。
static void GetDatesFromMonth(string month, ref DateTime fromDate, ref DateTime toDate)
{
DateTime userDateTime = TimeHelper.getUserGMTNow();
DateTime calculatedDate = Convert.ToDateTime(month + " 01," + userDateTime.Year);
toDate = calculatedDate.AddMonths(1).AddSeconds(-1);
fromDate = toDate.AddMonths(-12).AddSeconds(1);
}
我在我的类文件中许多地方都使用了这段代码。
当我在我的代码上运行Resharper时,它会显示此消息,与其所有其他建议不同,它无法更正此代码块。
有人能帮我用较好的编码实践重写这个方法吗?