Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-290680: 'Convert to foreach' generates non-compilable code

$
0
0
Reporter Andrew Serebryansky (andrew.serebryansky) Andrew Serebryansky (andrew.serebryansky)
Created Mar 20, 2012 3:04:19 PM
Updated Mar 20, 2012 3:04:19 PM
Priority Major
Type Bug
Fix versions No Fix versions
State Open
Assignee Alexey Kuptsov (alexey.kuptsov)
Subsystem No subsystem
Affected versions 6.1.1
Fixed in build No Fixed in build
I have this for loop:

for (int i = 0; i < messages.Length; i++)
{
string singleMessage = messages[i];
if (singleMessage.Contains("EOM"))
{
singleMessage = singleMessage.Replace("EOM", "");
}
}

ReSharper suggests me to convert it to a foreach loop. The final result would be this:

foreach (string singleMessage in messages)
{ if (singleMessage.Contains("EOM"))
{
singleMessage = singleMessage.Replace("EOM", "");
}
}

However now the singleMessage variable is readonly and it can not be assigned and the project will not compile.

Viewing all articles
Browse latest Browse all 106942

Trending Articles