It's possible to obtain a collection of all objects of certain class?
Given some arbitrary class, for example:
public class MyClass {
public int anyVal;
/* ...etc ... */
}
Is it possible to obtain a collection of all objects of certain class so you can iterate through them, like perhaps:
MyClass obj = new MyClass();
obj.anyVal = 333;
MyClass[] allObjects = //??? // <== HERE
foreach (MyClass mObj in allObjects) {
Console.WriteLine("obj = " + mObj.anyVal);
}