Reputation: 1507
public class A
{
public int i;
public string s;
}
public class B
{
public int bi;
public A A;
}
Here I get the properties of class B
which in turn returns both the properties available.
However I need to differentiate the normal class properties to the complex properties.
I need to handle the property A
of class B
differently. Can somebody advise how I can write code to decide that this property is of type of another class?
I just gave an example of Class A
as child in Class B
here. In real-time, there can be many children.
Upvotes: 0
Views: 272
Reputation: 6683
I'm going to assume that by "normal class properties" and "complex properties" you mean value and reference types, as that's what your example seems to imply.
If this is the case, you can use Type.IsValueType
to check whether the type of each field or property is a value type. If it isn't a value type, that means it is a reference to another class, and you can act accordingly.
Upvotes: 2