I don't know of a built in mechanism, but you can always incrase a private static variable in constructor.
public class MyClass
{
private static int instances = 0;
public MyClass() => instances++;
~MyClass() => instances--;
}
Haven't tried but should work.