class Program
{
static void Main(string[] args)
{
foreach (var num in GetNumbers())
{
}
}
static IEnumerable<int> GetNumbers()
{
return new[] { 1, 2, 3 };
}
}
Highlight "GetNumbers()" in the foreach statement and use Ctrl+. to get the light bulb. Invoke "Introduce Local". Observe that the new local is named "enumerable".
Since we have code to detect known patterns like "GetBlah", it would be nice if we could notice that the Expression of the ForEachStatementSyntax was an InvocationExpression and try to recognize that pattern.