Somehow following code doesn't compile in VS2010 but compiles in VS2012 without changes. The problematic line in VS2010 is
names.Select(foo.GetName)
error CS1928: 'string[]' does not contain a definition for 'Select' and the best extension method overload 'System.Linq.Enumerable.Select<TSource,TResult>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,TResult>)' has some invalid arguments.
using System;
using System.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
var foo = new Foo();
var names = new[] {"Hello"};
Console.WriteLine(string.Join(", ", names.Select(foo.GetName)));
}
}
public class Foo
{
}
static class Extensions
{
public static string GetName(this Foo foo, string name)
{
return name;
}
}
}