Dynamic cast given a class reference?

Given the screenshot below:
The method is supplied with an actors[] and targetClass. I’d like to destroy actors that match with targetClass, and I figured the best way would be to cast an object targetClass.

Is this possible? Otherwise I could just filter the array externally and just destroy all the provided actors[] instead.


Edit[0]: shrug I just decided to pre-filter the array. However, I’d still like to know if there’s a solution to my original question.