Incorrect suggestion for for loop
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.
Please sign in to leave a comment.
Hello Jarzka
Thank you for reporting this bug! I've logged it under http://youtrack.jetbrains.com/issue/RSRP-290680 and you're welcome to monitor the status of this issue.
Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"