ReSharper 2026.1 Help

Code inspection: Redundant 'string.ToCharArray()' call

This inspection reports a call to ToCharArray() inside a foreach when the code can iterate over the string directly. The extra array allocation does not change the result and only adds unnecessary work.

Example

foreach (char c in text.ToCharArray()) { Consume(c); }
foreach (char c in text) { Consume(c); }

Quick-fix

The quick-fix removes the ToCharArray() call and iterate over the string directly.

13 April 2026