Version Used:
Visual Studio 2019 v16.7.2
Steps to Reproduce:
List<string> source = new List<string> {"A", "B", "C"};
List<string> items = new List<string>(source);
// ^^^ IDE0028: Collection can be simplified
items[^1] = "X";
Applying the suggested fix results in the next broken code:
List<string> items = new List<string>(source)
{
[^1] = "X" // CS1913: Member '[^1]' cannot be initialized. It is not a field or property.
};
Version Used:
Visual Studio 2019 v16.7.2
Steps to Reproduce:
Applying the suggested fix results in the next broken code: