Horev Ivan
Horev Ivan

Reputation: 268

Find all Func delegates

Why

var funcDelegatesCount = Assembly.Load("mscorlib")
        .GetTypes()
        .Count(t => 
               t.Name.StartsWith("Func`") 
            && t.BaseType == typeof(MulticastDelegate));

returns 9. But in fact there are 17.

Upvotes: 2

Views: 97

Answers (1)

Athari
Athari

Reputation: 34295

Huh. The answer is funny.

  • Func<> to Func<,,,,,,,,> are in mscorlib assembly.

  • Func<,,,,,,,,> to Func<,,,,,,,,,,,,,,,,> are in System.Core assembly.

Check:

Console.WriteLine("{0} != {1}",
    typeof(Func<,,,,,,,,>).Assembly, typeof(Func<,,,,,,,,,>).Assembly);

Upvotes: 4

Related Questions