Reporter | Anatoly Nikitin (Anatoly.Nikitin) |
---|---|
Created | Mar 29, 2011 8:32:09 PM |
Updated | Feb 2, 2012 9:15:07 PM |
Resolved | Feb 2, 2012 4:30:17 PM |
Priority | Critical |
Type | Bug |
Fix versions | 6.1 |
State | Fixed |
Assignee | Valentin Kipiatkov (valentin) |
Subsystem | LINQ Tools |
Affected versions | No Affected versions |
Fixed in build | 6.5.1.3937 |
Consider the following method:
void Foo()
{
int[] array = new [] {3, 4};
List<int> list = new List<int>();
foreach(int a in array)
{
int group = a * a;
if(group > 10)
list.Add(group/2);
}
}
Resharper suggests to convert "foreach" loop into LINQ-expression. Here is what we get after conversion:
List<int> list = (from a in array select a * a into @group where group > 10 select group / 2).ToList();
Obviously, this causes compilation error, because "group" doesn't have "@" in the beginning.
void Foo()
{
int[] array = new [] {3, 4};
List<int> list = new List<int>();
foreach(int a in array)
{
int group = a * a;
if(group > 10)
list.Add(group/2);
}
}
Resharper suggests to convert "foreach" loop into LINQ-expression. Here is what we get after conversion:
List<int> list = (from a in array select a * a into @group where group > 10 select group / 2).ToList();
Obviously, this causes compilation error, because "group" doesn't have "@" in the beginning.