Timo
Timo

Reputation: 9835

Check if an ITypeSymbol is a delegate type

How can I check if an ITypeSymbol instance refers to a delegate type (like Action or Func<T>).

I think I can check if the base type is System.Delegate. Is this the correct way to do so or is there a better solution?

Upvotes: 3

Views: 253

Answers (1)

canton7
canton7

Reputation: 42235

Check its TypeKind:

typeSymbol.TypeKind == TypeKind.Delegate;

Upvotes: 7

Related Questions