I know that you can call an instance method that executes for each object. I also know that you can have a static method on the type that is callable from the type.
But how would one call a method that acts on every instance of a particular type (say, to set a member variable to zero, for example)?
C# doesn’t provide a direct mechanism to track all reachable objects and there’s almost never a good reason to want such automatic tracking functionality (rather than, say, an explicit pool that you manage yourself).
But to answer your requirement directly, you’ll need to:
All of this will have to be done in a thread-safe manner.
Are you sure you need all of this though? This is all really strange and non-deterministic (will be heavily impacted by when garbage-collection occurs).