How to get the parent class of an object with a null value?
For instance...
ClassAcontains int? i, which is not set to any value when creating the class.
Then in some other place in the code I want to pass ias a parameter to some function. Using ias the only information, I want to understand what ClassA“belongs” i.
The reason for this is that it ClassAalso contains some other object, and I want to call this different value of the object the same function mentioned in the previous paragraph.
It may 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 = ;
int someValue = (int)theObject;
}
source
share