Why does Resharper say, “Co-variant array conversion from string[] to object[] can cause run-time exception on write operation” with this code? [duplicate]

The method comboBoxMonth.Items.AddRange expects an object[] parameter. months.ToArray() is string[]. A cast from string[] to object[] is valid, but if the method tries to modify elements of the array, you will get run-time errors. In this case it doesn’t, so you can ignore the warning. If it annoys you, you can use ToArray<object>() comboBoxMonth.Items.AddRange(UsageRptConstsAndUtils.months.ToArray<object>()); It … Read more

Covariant generic parameter

Can someone explain the usage of the out T part with an example? Sure. IEnumerable<T> is covariant. That means you can do this: static void FeedAll(IEnumerable<Animal> animals) { foreach(Animal animal in animals) animal.Feed(); } … IEnumerable<Giraffe> giraffes = GetABunchOfGiraffes(); FeedAll(giraffes); “Covariant” means that the assignment compatibility relationship of the type argument is preserved in the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)