How would I get the parent class of an object that has a value of null?
For example...
ClassA
contains int? i
which is not set to any value when the class is created.
Then in some other place in the code I want to pass in i
as a parameter to some function. Using i
as the only info, I want to be able to figure out that ClassA
"owns" i
.
The reason for this is because ClassA
also contains some other object, and I want to call this other object's value from that same function mentioned in the above paragraph.
Could also be:
public class A
{
public class B
{
public int? i;
public int? j;
}
B classBInstance = new B();
public string s;
}
{
...
A someClassAInstance = new A();
...
doSomething(someClassAInstance.classBInstance.i);
...
}
public static bool doSomething(object theObject)
{
string s = /* SOMETHING on theObject to get to "s" from Class A */;
int someValue = (int)theObject;
}