这段代码:
comboBoxMonth.Items.AddRange(UsageRptConstsAndUtils.months.ToArray());
public static List<String> months = new List<String>
{
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
};
针对“Co-variant array conversion from string[] to object[] can cause run-time exception on write operation”的抱怨,导致R#变得像个吝啬鬼。
实际上,这段代码完美运行——组合框中填充了月份值; 那么Resharper指的是什么?我该如何缓解它的疑虑?
如果只是因为通用列表中可能包含错误数据,那我就不会担心——如果真有问题,追踪问题也很容易。
List<object>
而不是List<string>
。 - Ron Beyer